Skip to content
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

Values will occasionally NaN when width and height cannot be obtained fr... #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DotFreelance
Copy link

...om ‘item’ object. Added code to check values and use this.width/this.height instead.

… from ‘item’ object. Added code to check values and use this.width/this.height instead.
@DotFreelance
Copy link
Author

When importing this library into a rather large project, found that occasionally the w and h variables would be 0, resulting in a divide by zero and an infinity/NaN result which completely disables the image maps. Adding the 4 lines of code corrected this problem. The code will not supersede what already exists.

@DotFreelance DotFreelance reopened this Apr 9, 2014
@coreyleelarson
Copy link

This pull request should really be accepted. I had this exact problem as well and this fix worked.

@jeremylcarter
Copy link

I used naturalHeight and naturalWidth but essentially its the same fix. Thanks for the pointers!

if(!w)
w = this.width;
if(!h)
h = this.height;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a bug like the one below, but thanks to you, I solved it. thank you!

image

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

Successfully merging this pull request may close these issues.

4 participants