javascript - How to figure out if CSS transition is about to happen? -
here's problem. let's alter div height 10px 50px , want calculations size.
normally i'd alter value , get, illustration true height (which can affected its/any of parents padding, max-heights, lot.).
however, when alter animated transition things complicated. can wait transitionend
event fire , check element size how can figure out transition happen? instead of checking height know have wait event?
test computed style of transition property. if matches property changing, wait transitionend event.
if(window.getcomputedstyle(element).transitionproperty.match(/\bheight\b/)) { //handle transitionend event } else { //do calculations }
of course of study need check browser's specific prefix.
edit: should element may have several transition properties set. create sure test accordingly (code updated reflect that).
javascript css
No comments:
Post a Comment