帮助这个动画循环
t.grow = function(parent,evt) {
evt.target.Y = 0
var r = parent.radius, that = this
this.loop = function() {
parent.root.suspendRedraw(10000)
evt.target.Y = evt.target.Y - 6
evt.target.setAttribute('transform',
'translate(' + 0 + ',' + evt.target.Y + ')')
r = r + 0.1
evt.target.setAttribute('r',r)
parent.root.unsuspendRedrawAll()
if(evt.target.Y < parent.timeout) {
clearInterval(that.timer)
}
}
that.timer = window.setInterval(this.loop,30)
}
this.el.addEventListener("mouseover",
function(event){
t.grow(parent,event)
},
true)
我真的需要一些有关上述动画的帮助。
目前,动画是在鼠标悬停在对象上时触发的,但我真正想要实现的是动画在事件上触发,我希望它在随机时间触发
t.grow = function(parent,evt) {
evt.target.Y = 0
var r = parent.radius, that = this
this.loop = function() {
parent.root.suspendRedraw(10000)
evt.target.Y = evt.target.Y - 6
evt.target.setAttribute('transform',
'translate(' + 0 + ',' + evt.target.Y + ')')
r = r + 0.1
evt.target.setAttribute('r',r)
parent.root.unsuspendRedrawAll()
if(evt.target.Y < parent.timeout) {
clearInterval(that.timer)
}
}
that.timer = window.setInterval(this.loop,30)
}
this.el.addEventListener("mouseover",
function(event){
t.grow(parent,event)
},
true)
I really need some help with the above animation.
At the moment the animation is triggered on a mouseover of the object, but what I would really like to achieve is rather than the animation being triggered on an event I would like it to fire at a random time
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,第二行创建一个 0 到 10 之间的随机数,然后加 5,这样就不会出现两个背靠背运行的动画。
Basically the second line creates a random number between 0 and 10 then it adds 5 so that you won't have two animations running back to back.