New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webkit calculating dimensions improperly #2
Conversation
Hi! I didn't notice any problem with the resizing with webkit. Same thing for the load event. Most (all?) of the bug are fixed by placing the .src settings after the event (what I did in the script). It works well on all the browser I tested it, Windows and MacOS). Can you, please help me to reproduce the bugs ? |
Take a look at http://www.simshaun.com/dev/js/vegas/. I've added a line to Vegas's resize method that logs the img width and height to the console. The first time each image is loaded, it should give the correct dimensions. Every time you click the images and it loads them from cache, you should be getting 0,0. |
Thanks Shaun! I tried different things on Chrome & Safari (pc) but I can't reproduce the bug. |
Very odd. Mine is doing it consistently (100% of the time) on the cached images in Chrome. Safari seems to be fine though, go figure. I'll also test this on Chrome when I get home tonight to verify that is not just this pc. Made a short video showing it just so you can see it @ http://vimeo.com/24016972 |
Verified that it is also occurring in Chrome on a second computer. |
I've just tried on Chrome/Mac at home. Your video is not working. Too bad, it could help me a lot. |
Odd. Try the download link at the bottom right on vimeo.
|
Ok, I've downloaded the video. What is the version of your Chrome ? |
Yep looks like you are doing the same thing as me. I'm running Chrome 11/Win7. Does it on Chrome 11/WinXP as well. Well I honestly don't know what to try now. Now I'm just wondering if there are any differences in Chrome that would affect this between Windows and Mac. Can you use the network tab of Chrome's dev tools to verify that it is not re-requesting the images the second time you click them? |
Hi, |
I'm not sure what else to do to help you reproduce it. Perhaps Chrome for Mac is not affected. Also, I just tested it on a 3rd computer (Vista) with a clean installation of Chrome and it does it there too. |
Hi Shaun, |
Hi Shaun, I finally manage to reproduce the bug. I used your solution (Paul Irish plugin) to fix it. Release 1.2 |
First off, great work in this plugin.
I've found that there is a bug with the plugin in Webkit-based browsers such as Chrome and Safari.
When resize() is called, $img.width() and $img.height() return 0, resulting in improper dimensions calculations. It does this because Webkit sets the width and height to 0 and only after the image has been loaded does it calculate the correct values. What this means is the .load() event can be (and for me, usually is) fired before Webkit reports the correct dimensions - essentially a race condition.
Also, the load event may not be fired for cached images in some browsers (as described in the API).
So, here's what I've done to fix both issues: