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

Listen for transitionend events #140

Merged
merged 2 commits into from
Jan 18, 2015

Conversation

outoftime
Copy link
Contributor

In Safari, I've observed situations along the lines of:

  • Changing the DOM class of an element initiates a height transition
  • When the attribute change is observed, Safari still reports the body
    height as its pre-transition value
  • Once transitionend fires, the reported height is correct

I do not observe this behavior on Chrome or Firefox, but the change
herein should not hurt in those browsers either.

Mat Brown added 2 commits January 11, 2015 14:29
In Safari, I've observed situations along the lines of:

* Changing the DOM class of an element initiates a height transition
* When the attribute change is observed, Safari still reports the body
  height as its pre-transition value
* Once `transitionend` fires, the reported height is correct

I do not observe this behavior on Chrome or Firefox, but the change
herein should not hurt in those browsers either.
@davidjbradshaw
Copy link
Owner

Hi,

That's a new event on me and I agree it's one we should be catching. I think rather than repeat the call to addEventListerner it would be better to do something like this.

if(Array.prototype.map){
    ['transitionend','webkitTransitionEnd','oTransitionEnd','otransitionend'].map(function(e){
        addEventListener(window,e,onTransitionEnd);
    });
}

Also any chance you can add a test case for this?

Thanks,
Dave.

@davidjbradshaw
Copy link
Owner

Or thinking about it a bit more it could be reduced down to.

if(Array.prototype.map){
    ['transitionend','webkitTransitionEnd','oTransitionEnd','otransitionend'].map(function(transitioned){
        addEventListener(window,transitioned,function(e){
            if (e.propertyName in {height:1,width:1}) {
                sendSize('transitionend','Transition end');
            }
        });
    });
}

davidjbradshaw added a commit that referenced this pull request Jan 18, 2015
@davidjbradshaw davidjbradshaw merged commit f3c98c0 into davidjbradshaw:master Jan 18, 2015
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