Skip to content

Commit

Permalink
fix : yoyo function
Browse files Browse the repository at this point in the history
これはTween.js側のバグです。一時的にyoyo関数を作成してパッチしています。
tweenjs/tween.js#677 (comment)
  • Loading branch information
MasatoMakino committed Jul 27, 2024
1 parent 2ae66b9 commit e0e967a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions demoSrc/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ export class Demo {

const circle = this.addCircle();

const yoyo = (f) => {
return (t) => {
if (t < 0.5) {
return f(2 * t);
} else {
return 1 - f(2 * (t - 0.5));
}
};
};

const tween = new Tween(circle.dataset)
.to({ rotation: 360, y: 300 }, 750)
.to({ rotation: 360, y: 300 }, 1500)
.repeat(Infinity)
.yoyo(true)
.easing(Easing.Cubic.InOut)
.easing(yoyo((t) => Easing.Cubic.InOut(t)))
.onUpdate((object) => {
this.updateBox(circle, object);
})
Expand Down

0 comments on commit e0e967a

Please sign in to comment.