@@ -135,18 +135,17 @@ new Vue({
135
135
},
136
136
watch: {
137
137
color : function () {
138
- var animationFrame
139
- function animate ( time ) {
140
- TWEEN . update (time )
141
- animationFrame = requestAnimationFrame (animate)
138
+ function animate () {
139
+ if ( TWEEN . update () ) {
140
+ requestAnimationFrame (animate )
141
+ }
142
142
}
143
+
143
144
new TWEEN.Tween (this .tweenedColor )
144
145
.to (this .color , 750 )
145
- .onComplete (function () {
146
- cancelAnimationFrame (animationFrame)
147
- })
148
146
.start ()
149
- animationFrame = requestAnimationFrame (animate)
147
+
148
+ animate ()
150
149
}
151
150
},
152
151
computed: {
@@ -212,18 +211,17 @@ new Vue({
212
211
},
213
212
watch: {
214
213
color: function () {
215
- var animationFrame
216
- function animate (time ) {
217
- TWEEN.update(time )
218
- animationFrame = requestAnimationFrame(animate)
214
+ function animate () {
215
+ if (TWEEN.update() ) {
216
+ requestAnimationFrame(animate )
217
+ }
219
218
}
219
+
220
220
new TWEEN.Tween(this.tweenedColor)
221
221
.to(this.color, 750)
222
- .onComplete(function () {
223
- cancelAnimationFrame(animationFrame)
224
- })
225
222
.start()
226
- animationFrame = requestAnimationFrame(animate)
223
+
224
+ animate()
227
225
}
228
226
},
229
227
computed: {
@@ -439,21 +437,20 @@ Vue.component('animated-integer', {
439
437
methods: {
440
438
tween : function (startValue , endValue ) {
441
439
var vm = this
442
- var animationFrame
443
- function animate ( time ) {
444
- TWEEN . update (time )
445
- animationFrame = requestAnimationFrame (animate)
440
+ function animate () {
441
+ if ( TWEEN . update () ) {
442
+ requestAnimationFrame (animate )
443
+ }
446
444
}
445
+
447
446
new TWEEN.Tween ({ tweeningValue: startValue })
448
447
.to ({ tweeningValue: endValue }, 500 )
449
448
.onUpdate (function () {
450
449
vm .tweeningValue = this .tweeningValue .toFixed (0 )
451
450
})
452
- .onComplete (function () {
453
- cancelAnimationFrame (animationFrame)
454
- })
455
451
.start ()
456
- animationFrame = requestAnimationFrame (animate)
452
+
453
+ animate ()
457
454
}
458
455
}
459
456
})
@@ -510,21 +507,20 @@ Vue.component('animated-integer', {
510
507
methods: {
511
508
tween : function (startValue , endValue ) {
512
509
var vm = this
513
- var animationFrame
514
- function animate ( time ) {
515
- TWEEN . update (time )
516
- animationFrame = requestAnimationFrame (animate)
510
+ function animate () {
511
+ if ( TWEEN . update () ) {
512
+ requestAnimationFrame (animate )
513
+ }
517
514
}
515
+
518
516
new TWEEN.Tween ({ tweeningValue: startValue })
519
517
.to ({ tweeningValue: endValue }, 500 )
520
518
.onUpdate (function () {
521
519
vm .tweeningValue = this .tweeningValue .toFixed (0 )
522
520
})
523
- .onComplete (function () {
524
- cancelAnimationFrame (animationFrame)
525
- })
526
521
.start ()
527
- animationFrame = requestAnimationFrame (animate)
522
+
523
+ animate ()
528
524
}
529
525
}
530
526
})
0 commit comments