Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d986f3

Browse files
committed
Fix broken non-animatable transition fallback
1 parent c597b8c commit 2d986f3

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

src/plots/plots.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,12 +1673,16 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts)
16731673
var trace = gd._fullData[traceIdx];
16741674
var module = trace._module;
16751675

1676-
if(!module || !module.animatable) {
1677-
continue;
1676+
// There's nothing to do if this module is not defined:
1677+
if(!module) continue;
1678+
1679+
// Don't register the trace as transitioned if it doens't know what to do.
1680+
// If it *is* registered, it will receive a callback that it's responsible
1681+
// for calling in order to register the transition as having completed.
1682+
if(module.animatable) {
1683+
transitionedTraces.push(traceIdx);
16781684
}
16791685

1680-
transitionedTraces.push(traceIdx);
1681-
16821686
gd.data[traceIndices[i]] = plots.extendTrace(gd.data[traceIndices[i]], data[i]);
16831687
}
16841688

test/jasmine/tests/animate_test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,3 +706,34 @@ describe('Animate API details', function() {
706706
}).catch(fail).then(done);
707707
});
708708
});
709+
710+
describe('non-animatable fallback', function() {
711+
'use strict';
712+
var gd;
713+
714+
beforeEach(function() {
715+
gd = createGraphDiv();
716+
});
717+
718+
afterEach(function() {
719+
Plotly.purge(gd);
720+
destroyGraphDiv();
721+
});
722+
723+
it('falls back to a simple update for bar graphs', function(done) {
724+
Plotly.plot(gd, [{
725+
x: [1, 2, 3],
726+
y: [4, 5, 6],
727+
type: 'bar'
728+
}]).then(function() {
729+
expect(gd.data[0].y).toEqual([4, 5, 6]);
730+
731+
return Plotly.animate(gd, [{
732+
data: [{y: [6, 4, 5]}]
733+
}], {frame: {duration: 0}});
734+
}).then(function() {
735+
expect(gd.data[0].y).toEqual([6, 4, 5]);
736+
}).catch(fail).then(done);
737+
738+
});
739+
});

0 commit comments

Comments
 (0)