Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tween object not pausing issue #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/charm.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class Charm {

//Create the tween object
let o = {};
o.playing = true;

//If the tween is a bounce type (a spline), set the
//start and end magnitude values
Expand All @@ -147,13 +148,13 @@ class Charm {

//Use `o.start` to make a new tween using the current
//end point values
o.start = (startValue, endValue) => {
o.start = (startValue, endValue, isPlaying = true) => {

//Clone the start and end values so that any possible references to sprite
//properties are converted to ordinary numbers
o.startValue = JSON.parse(JSON.stringify(startValue));
o.endValue = JSON.parse(JSON.stringify(endValue));
o.playing = true;
o.playing = isPlaying;
o.totalFrames = totalFrames;
o.frameCounter = 0;

Expand Down Expand Up @@ -213,9 +214,6 @@ class Charm {
//The `end` method will be called when the tween is finished
o.end = () => {

//Set `playing` to `false`
o.playing = false;

//Call the tween's `onComplete` method, if it's been assigned
if (o.onComplete) o.onComplete();

Expand All @@ -227,8 +225,10 @@ class Charm {
//as the next tween's `endValue`
if (yoyo) {
this.wait(delayBeforeRepeat).then(() => {
o.start(o.endValue, o.startValue);
o.start(o.endValue, o.startValue, o.playing);
});
} else {
o.playing = false;
}
};

Expand Down