我正在父div上运行Transitionend,因为我想等到该过渡完成。不幸的是,有一个子按钮具有一个过渡,该过渡触发了transitionend事件在父div完成过渡之前运行。我已经尝试过使用event.stopPropagation(),但是没有运气。
transitionend仅触发一次,而不是针对所有转换触发,因此我无法按event.target进行过滤。
<div class="section">
<div class="fp-tableCell">
<a href="http://www.gosomewhere.com" class="btn">View</a>
</div>
</div>
function whichTransitionEvent(){
var t,
el = document.createElement("fakeelement");
var transitions = {
"transition" : "transitionend",
"OTransition" : "oTransitionEnd",
"MozTransition" : "transitionend",
"WebkitTransition": "webkitTransitionEnd"
};
for (t in transitions){
if (el.style[t] !== undefined){
return transitions[t];
}
}
}
var transitionEvent = whichTransitionEvent();
var fpSection = $('.section.active').children('.fp-tableCell');
fpSection.one(transitionEvent, function (event) {
console.log('do stuff');
});
任何帮助都会很棒。谢谢