joh*_*nny 5 html5 css3 css-transitions
有没有办法在我的Javascript中检测一个元素当前是否正在使用CSS3过渡动画?
一个"transitionstart"-event(相当于'transistionend'事件)也可以解决,但我在规范中找不到任何提及它.
好吧,由于只有一个transitionend事件(http://www.w3.org/TR/css3-transitions/#transition-events),我想到了一些丑陋的东西:
http://jsfiddle.net/coma/psbBg/6/
JS
$(function() {
var div = $('div');
var property = div.css('transition-property');
var lastValue = div.css(property);
setInterval(function() {
if(lastValue !== div.css(property)) {
console.log('changed!');
}
lastValue = div.css(property);
}, 10);
});
Run Code Online (Sandbox Code Playgroud)
它可以改进实现自定义事件,注意获取正确的转换属性(或多个属性),以及更多想法,但您明白了吗?
也许你需要采取另一条路来解决你原来的问题......