[英]JavaScript Timing with CSS timing
consider this CSS property: 考虑以下CSS属性:
.front{
transition: left 2s;
left : 0px;
}
and this JQuery function : 和这个JQuery函数:
var delay = 5000;
setTimeout(function(){
$('.front').animate({left: '1300px'}, { duration: 500});
,delay}
Now the duration is 0.5 second . 现在持续时间为0.5秒。 Delay is set to 5 seconds . 延迟设置为5秒。 Transition timing is 2 seconds . 过渡时间为2秒。
I have done lots of attempts to figure out who wins the war of timing, but i couldn't. 我做了很多尝试来弄清楚谁赢得了计时战,但我做不到。
could you help me and tell me what really goes on when the script runs ? 您能帮我一下,告诉我脚本运行时真正发生了什么吗?
EDIT : I added the initial position property in the css class ; 编辑:我在css类中添加了初始position属性; forgot to add it tho . 忘记添加它。
Your script: 您的脚本:
Based on what your showing us, the CSS doesn't really do anything. 根据您向我们展示的内容,CSS实际上并没有做任何事情。 Note that CSS transitions aren't the same as jQuery animations. 请注意,CSS过渡与jQuery动画不同。
UPDATE: 更新:
An example based on my comments: 基于我的评论的示例:
.front{
left: 500px
transition: left 2s;
}
.front.animate {
left: 0px;
}
var delay = 5000;
setTimeout(function(){
$('.front').addClass('animate');
,delay}
Fiddle: http://jsfiddle.net/9q8sL/1/ 小提琴: http : //jsfiddle.net/9q8sL/1/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.