Skip to content

Commit

Permalink
Merge branch 'develop' (closes #105)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed Nov 16, 2018
2 parents 057fc04 + acbde2f commit 2cfe081
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shifty",
"version": "2.6.0",
"version": "2.6.1",
"homepage": "http://jeremyckahn.github.io/shifty/doc/",
"author": "Jeremy Kahn <[email protected]>",
"repository": {
Expand Down
9 changes: 7 additions & 2 deletions src/tweenable.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,13 @@ const remove = tween => {
const previousTween = tween._previous;
const nextTween = tween._next;

previousTween._next = nextTween;
nextTween._previous = previousTween;
if (previousTween) {
previousTween._next = nextTween;
}

if (nextTween) {
nextTween._previous = previousTween;
}
}
};

Expand Down
58 changes: 58 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,64 @@ describe('shifty', () => {
'The tweened value jumps to the end'
);
});

describe('repeated calls (#105)', () => {
describe('first tween is stopped twice', () => {
beforeEach(() => {
Tweenable.now = () => 0;

let { tweenable } = tween({
from: { x: 0 },
to: { x: 10 },
duration: 500,
});

tween({
from: { x: 0 },
to: { x: 10 },
duration: 500,
});

Tweenable.now = () => 250;
processTweens();

tweenable.stop(true);
tweenable.stop(true);
});

it('does not break when multiple tweens are running and stop() is called twice', () => {
assert(true);
});
});

describe('second tween is stopped twice', () => {
beforeEach(() => {
Tweenable.now = () => 0;

tween({
from: { x: 0 },
to: { x: 10 },
duration: 500,
});

let { tweenable } = tween({
from: { x: 0 },
to: { x: 10 },
duration: 500,
});

Tweenable.now = () => 250;
processTweens();

tweenable.stop(true);
tweenable.stop(true);
});

it('does not break when multiple tweens are running and stop() is called twice', () => {
assert(true);
});
});
});
});

describe('#setScheduleFunction', () => {
Expand Down

0 comments on commit 2cfe081

Please sign in to comment.