【发布时间】:2016-08-13 21:11:07
【问题描述】:
以下代码创建了一个GSAP TimelineMax,它在第一次播放时完美运行。但是,在时间轴反转并且您再次播放后,TimelineMax 的后半部分“丢失”了。
var tl = new TimelineMax();
$(".box").hover(function(){
tl = new TimelineMax();
tl.to($(this).children("span.short"), 0.5, {scale: 0})
.set($(this).children("span.short"), {css:{display: "none"}})
.set($(this).children("span.long"), {css:{display: "block"}})
.from($(this).children("span.long"), 0.5, {scale: 0});
},function() {
tl.reverse();
});
.box {
width: 200px;
height:100px;
text-align:center;
background: black
}
span {
color: white
}
.short {
display: block
}
.long {
display: none
}
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TweenMax.min.js"></script>
<div class="box">
<span class="short">S</span>
<span class="long">Long</span>
</div>
这里是JSFiddle,如果您愿意使用的话。
如果能在修复时间线以使其正常运行方面提供任何帮助,我将不胜感激。
注意:你需要将鼠标悬停在盒子上才能看到动画
【问题讨论】:
标签: javascript jquery html css gsap