Re: [polymer-dev] Element works fine locally, but demo on GH Pages fails

93 views
Skip to first unread message

Eric Bidelman

unread,
May 19, 2014, 10:16:56 PM5/19/14
to Karan Goel, polymer-dev
Karan, did you get this squared away? It seems like the demo is working again.


On Mon, May 19, 2014 at 7:25 AM, Karan Goel <karan...@gmail.com> wrote:
So for x-meme (https://github.com/karan/x-meme), running it locally works fine but on GH pages, the images are all messed up: http://karan.github.io/x-meme/components/x-meme/demo.html

What's happening is I'm getting the width of image after it's loaded to set width of everything else, but (look in the console when opening demo page) it actually gets a width of 0px. I think it's because it get's the width before image has loaded, but I'm not sure why, I am doing everything after onload event.

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/7f75ef36-a831-4f2b-b212-351141205ad5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Karan Goel

unread,
May 19, 2014, 10:22:21 PM5/19/14
to Eric Bidelman, polymer-dev

Yes I did Eric. I used polymer event handler and that seemed to work.

- Karan Goel
Sent from Nexus 4. Please ignore typos and abbreviations.

Scott Miles

unread,
May 19, 2014, 10:28:40 PM5/19/14
to Karan Goel, Eric Bidelman, polymer-dev
Because the image isn't part of the main document, it's not guaranteed to be available at body.onload time.

Listening for the image's own onload event is the right solution. 



Karan Goel

unread,
May 19, 2014, 10:34:24 PM5/19/14
to Scott Miles, Eric Bidelman, polymer-dev
So earlier I was listening for `onload` event in the image, but then I did not have access to everything else because of scoping. So I put the width setting code in domReady which was working fine locally but not on GH pages. I don't know why.

Karan Goel

Scott Miles

unread,
May 19, 2014, 10:39:59 PM5/19/14
to Karan Goel, Eric Bidelman, polymer-dev
`domReady` has no guarantee that async resources like images are loaded, you have to listen to the image itself, as you did.

You can attach to the image's load event several ways, using Polymer's 'on-load' is not special other than being super convenient.

Scott

Karan Goel

unread,
May 19, 2014, 10:43:31 PM5/19/14
to Scott Miles, Eric Bidelman, polymer-dev
That makes sense. Is there a good reference to what guarantees events like created, ready, domReady etc make? The polymer API page wasn't very descriptive.

Karan Goel

Eric Bidelman

unread,
May 19, 2014, 10:47:28 PM5/19/14
to Karan Goel, Scott Miles, polymer-dev

Karan Goel

unread,
May 19, 2014, 10:55:13 PM5/19/14
to Eric Bidelman, Scott Miles, polymer-dev
Yeah I didn't find the API to be specific enough for me. But the FAQ is golden. Thanks.

Karan Goel
Reply all
Reply to author
Forward
0 new messages