小编Pik*_*_at的帖子

检测过渡端的属性

我试图检测在具有不同延迟的同一元素的多个转换的情况下完成转换的属性,例如:

var cssTransitionEnd = 'webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend';
$('div').on(cssTransitionEnd, function(e) {
  var borderColorEnd, backgroundColorEnd;
  
  // Detect if this is border or background who ended ?
  
  if(borderColorEnd) {
    
  }
  if(backgroundColorEnd) {
    
  }
});
Run Code Online (Sandbox Code Playgroud)
div {
  width: 200px;
  height: 200px;
  background-color: red;
  border: 4px solid yellow;
  transition: border-color 1s, background-color 2s;
}
div:hover {
  border-color: green;
  background-color: blue;
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div></div>
Run Code Online (Sandbox Code Playgroud)

javascript css jquery css-transitions

4
推荐指数
1
解决办法
2745
查看次数

标签 统计

css ×1

css-transitions ×1

javascript ×1

jquery ×1