Skip to content

Problem with p5.Element.size() in Chrome/Chromium #613

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

Closed
xty opened this issue May 7, 2015 · 5 comments
Closed

Problem with p5.Element.size() in Chrome/Chromium #613

xty opened this issue May 7, 2015 · 5 comments

Comments

@xty
Copy link
Contributor

xty commented May 7, 2015

After trying out this example from the Beyond the Canvas tutorial, I discovered that setting either the width or height argument of the p5.Element.size() function to AUTO renders the affected <img> element invisible 🙈 in Chrome or Chromium, though everything works fine in Firefox. The failed tests were made in Chrome Version 42.0.2311.135 /w Windows 8.1 Pro (64-bit) and Chromium Version 41.0.2272.76 /w Ubuntu 14.10 (64-bit). Viewing the elements using the Chrome DevTools discloses the reason behind: whichever argument set to AUTO actually becomes zero. That is, following the aforementioned example and calling img.size(200, AUTO); will result in an <img> element with width="200" height="0".

@NPN
Copy link

NPN commented Jun 9, 2015

When img.set(200, AUTO) is called, img is still loading so both height and width are zero. Trying to scale a 0x0 pixel picture results in the height getting set to NaNpx, which is basically 0px.

createImg should allow a callback function to be passed in so it's possible to know when the image is loaded and ready to be used (see #561 and #578).

@lmccart
Copy link
Member

lmccart commented Jul 17, 2015

closed with 9015ffe

@lmccart lmccart closed this as completed Jul 17, 2015
@freder
Copy link

freder commented Oct 12, 2015

@lmccart @futuremarc
this only works though if the alt argument is provided, which should be optional.

@futuremarc
Copy link
Contributor

Actually, you can pass in a function to either the 2nd or 3rd arg, so you dont need to provide an alt tag. I guess this should be made clear in the docs

@freder
Copy link

freder commented Oct 13, 2015

oh, my bad: updated only p5.js and not p5.dom.js — so I was using an older version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants