Skip to content

Avoid non-initialized resize-sensor width/heights. #8

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

Merged
merged 1 commit into from
Jan 26, 2014

Conversation

maskmaster
Copy link
Contributor

There is an issue when an element initially has zero width or height. The initialization does not set the resize-sensor-underflow to correctly pick up resize events in these cases. Additionally Firefox and Chrome seems to optimize away any underflow event to a div with no area.

The fix makes sure that the resize-sensors will get intializes correctly. It would be possible to initialize to 'null' instead, but then the comparisons afterwards needs to be a bit more strict.

…lly has zero width or height. The underflow will never trigger in these cases otherwise.
@marcj
Copy link
Owner

marcj commented Jan 25, 2014

Mh, I'm not sure about that. Can you create please a test case (jsfiddle) where the current resize-sensor fails?

@maskmaster
Copy link
Contributor Author

Me an jsfiddle don't get along, so I rather explain the logic error that was fixed. If the height variable is initialized to 0 and the resize sensor initially is zero-height. What will happen in the setupSensor the first time it is called? Neither firstStyle or lastStyle will be initialized. Resize of the main resizeSensor will not trigger overflow (since resizeSensor cannot become less than 0 in height. Also the underflow will not trigger since it is already the same size or less than the resizeSensor.

marcj pushed a commit that referenced this pull request Jan 26, 2014
Avoid non-initialized resize-sensor width/heights.
@marcj marcj merged commit 2401a15 into marcj:master Jan 26, 2014
@marcj
Copy link
Owner

marcj commented Jan 26, 2014

Ok, makes sense to me. Thanks for the explantation and pr!

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.

2 participants