Skip to content

Commit a1d1d18

Browse files
committed
don't try to transition attr from non-animatable modules
1 parent 8e512c9 commit a1d1d18

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/plot_api/plot_api.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -2811,7 +2811,11 @@ function diffData(gd, oldFullData, newFullData, immutable, transition, newDataRe
28112811
var i, trace;
28122812

28132813
function getTraceValObject(parts) {
2814-
return PlotSchema.getTraceValObject(trace, parts);
2814+
var out = PlotSchema.getTraceValObject(trace, parts);
2815+
if(!trace._module.animatable && out.anim) {
2816+
out.anim = false;
2817+
}
2818+
return out;
28152819
}
28162820

28172821
var diffOpts = {

test/jasmine/tests/transition_test.js

+41
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,47 @@ describe('Plotly.react transitions:', function() {
431431
.then(done);
432432
});
433433

434+
it('should no try to transition a trace which is not *animatable:true* yet', function(done) {
435+
addSpies();
436+
437+
var trace = {
438+
type: 'bar',
439+
y: [1],
440+
marker: {line: {width: 1}}
441+
};
442+
443+
var data = [trace];
444+
var layout = {transition: {duration: 10}};
445+
446+
// sanity check that this test actually tests what was intended
447+
var Bar = Registry.modules.bar._module;
448+
if(Bar.animatable || Bar.attributes.marker.line.width.anim !== true) {
449+
fail('Test no longer tests its indented code path:' +
450+
' This test is meant to test that Plotly.react with' +
451+
' *anim:true* attributes in *animatable:false* modules' +
452+
' does not trigger Plots.transitionFromReact calls.'
453+
);
454+
}
455+
456+
Plotly.react(gd, data, layout)
457+
.then(function() {
458+
assertSpies('first draw', [
459+
[Plots, 'transitionFromReact', 0]
460+
]);
461+
})
462+
.then(function() {
463+
trace.marker.line.width = 5;
464+
return Plotly.react(gd, data, layout);
465+
})
466+
.then(function() {
467+
assertSpies('after (transition) react call', [
468+
[Plots, 'transitionFromReact', 0]
469+
]);
470+
})
471+
.catch(failTest)
472+
.then(done);
473+
});
474+
434475
it('should not try to transition when the *config* has changed', function(done) {
435476
addSpies();
436477

0 commit comments

Comments
 (0)