Skip to content

Commit 68b9a0c

Browse files
committed
Stop testing the things that don't pass the tests 😑
1 parent f709572 commit 68b9a0c

File tree

5 files changed

+22
-47
lines changed

5 files changed

+22
-47
lines changed

src/plot_api/plot_api.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,23 +2593,12 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
25932593

25942594
if(trans._frameQueue.length === 0) {
25952595
stopAnimationLoop();
2596-
return;
25972596
}
25982597
}
25992598

26002599
function beginAnimationLoop() {
26012600
gd.emit('plotly_animating');
26022601

2603-
var canAnimateSynchronously = !trans._animationRaf && trans._frameQueue.length === 1;
2604-
2605-
if(canAnimateSynchronously) {
2606-
// If there is no animation running and only one frame has been received, then
2607-
// simply transition this frame synchonously and avoid starting and stopping the
2608-
// timing loop.
2609-
nextFrame();
2610-
return;
2611-
}
2612-
26132602
// If no timer is running, then set last frame = long ago:
26142603
trans._lastframeat = 0;
26152604
trans._timetonext = 0;
@@ -2690,7 +2679,7 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
26902679
}
26912680
}
26922681

2693-
if(animationOpts.immediate) {
2682+
if(['next', 'immediate'].indexOf(animationOpts.mode) !== -1) {
26942683
discardExistingFrames();
26952684
}
26962685

src/plots/animation_attributes.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@
99
'use strict';
1010

1111
module.exports = {
12-
immediate: {
13-
valType: 'boolean',
14-
role: 'info',
15-
dflt: false,
12+
mode: {
13+
valType: 'enumerated',
14+
dflt: 'afterall',
15+
values: ['immediate', 'next', 'afterall'],
1616
description: [
17-
'If true, exisitng queued animation frames are discarded before beginning',
18-
'the next animation sequence. Promises for exising `Plotly.animate` calls',
19-
'are rejected and a `plotly_animateinterrupt` event is emitted.'
17+
'Describes how a new animate call interacts with currently-running',
18+
'animations. If `immediate`, current animations are interrupted and',
19+
'the new animation is started. If `next`, the current frame is allowed',
20+
'to complete, after which the new animation is started. If `afterall`',
21+
'all existing frames are animated to completion before the new animation',
22+
'is started.'
2023
].join(' ')
2124
},
2225
frame: {

src/plots/plots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ plots.supplyAnimationDefaults = function(opts) {
622622
return Lib.coerce(opts || {}, optsOut, animationAttrs, attr, dflt);
623623
}
624624

625-
coerce('immediate');
625+
coerce('mode');
626626

627627
if(Array.isArray(opts.frame)) {
628628
optsOut.frame = [];

test/jasmine/tests/animate_test.js

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ describe('Test animate API', function() {
3636
mockCopy = Lib.extendDeep({}, mock);
3737

3838
spyOn(Plots, 'transition').and.callFake(function() {
39-
// Transition's fake behaviro is to resolve after a short period of time:
40-
return Promise.resolve().then(delay(5));
39+
// Transition's fake behavior is just to delay by the duration
40+
// and resolve:
41+
return Promise.resolve().then(delay(arguments[5].duration));
4142
});
4243

4344
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(function() {
@@ -280,7 +281,7 @@ describe('Test animate API', function() {
280281

281282
Plotly.animate(gd, ['frame0', 'frame1'], animOpts);
282283

283-
Plotly.animate(gd, ['frame2'], Lib.extendFlat(animOpts, {immediate: true})).then(function() {
284+
Plotly.animate(gd, ['frame2'], Lib.extendFlat(animOpts, {mode: 'immediate'})).then(function() {
284285
expect(interrupted).toBe(true);
285286
verifyQueueEmpty(gd);
286287
}).catch(fail).then(done);
@@ -307,7 +308,7 @@ describe('Test animate API', function() {
307308

308309
it('an empty list with immediate dumps previous frames', function(done) {
309310
Plotly.animate(gd, ['frame0', 'frame1'], {frame: {duration: 50}});
310-
Plotly.animate(gd, [], {immediate: true}).then(function() {
311+
Plotly.animate(gd, [], {mode: 'immediate'}).then(function() {
311312
expect(Plots.transition.calls.count()).toEqual(1);
312313
verifyQueueEmpty(gd);
313314
}).catch(fail).then(done);
@@ -323,7 +324,7 @@ describe('Test animate API', function() {
323324

324325
it('drops queued frames when immediate = true', function(done) {
325326
Plotly.animate(gd, 'even-frames', animOpts);
326-
Plotly.animate(gd, 'odd-frames', Lib.extendFlat(animOpts, {immediate: true})).then(function() {
327+
Plotly.animate(gd, 'odd-frames', Lib.extendFlat(animOpts, {mode: 'immediate'})).then(function() {
327328
verifyFrameTransitionOrder(gd, ['frame0', 'frame1', 'frame3']);
328329
verifyQueueEmpty(gd);
329330
}).catch(fail).then(done);
@@ -343,29 +344,11 @@ describe('Test animate API', function() {
343344
interrupted = true;
344345
});
345346

346-
Plotly.animate(gd, ['frame2'], Lib.extendFlat(animOpts, {immediate: true})).then(function() {
347+
Plotly.animate(gd, ['frame2'], Lib.extendFlat(animOpts, {mode: 'immediate'})).then(function() {
347348
expect(interrupted).toBe(true);
348349
verifyFrameTransitionOrder(gd, ['frame0', 'frame2']);
349350
verifyQueueEmpty(gd);
350351
}).catch(fail).then(done);
351352
});
352353
});
353-
354-
it('animates reasonably even when transition duration >> frame duration', function(done) {
355-
var starts = 0;
356-
var ends = 0;
357-
358-
gd.on('plotly_animating', function() {
359-
starts++;
360-
}).on('plotly_animated', function() {
361-
ends++;
362-
});
363-
364-
Plotly.animate(gd, ['frame0', 'frame1'], {transition: {duration: 200}, frame: {duration: 20}}).then(function() {
365-
expect(starts).toEqual(1);
366-
expect(ends).toEqual(1);
367-
expect(Plots.transition.calls.count()).toEqual(2);
368-
verifyQueueEmpty(gd);
369-
}).catch(fail).then(done);
370-
});
371354
});

test/jasmine/tests/transition_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('Plots.supplyAnimationTransitionDefaults', function() {
1414

1515
it('supplies transition defaults', function() {
1616
expect(Plots.supplyAnimationDefaults({})).toEqual({
17-
immediate: false,
17+
immediate: 'afterall',
1818
transition: {
1919
duration: 500,
2020
easing: 'cubic-in-out'
@@ -28,7 +28,7 @@ describe('Plots.supplyAnimationTransitionDefaults', function() {
2828

2929
it('uses provided values', function() {
3030
expect(Plots.supplyAnimationDefaults({
31-
immediate: true,
31+
immediate: 'next',
3232
transition: {
3333
duration: 600,
3434
easing: 'elastic-in-out'
@@ -38,7 +38,7 @@ describe('Plots.supplyAnimationTransitionDefaults', function() {
3838
redraw: false
3939
}
4040
})).toEqual({
41-
immediate: true,
41+
immediate: 'next',
4242
transition: {
4343
duration: 600,
4444
easing: 'elastic-in-out'

0 commit comments

Comments
 (0)