Skip to content

Commit aaf9087

Browse files
committed
Minor fixes to allow null frames internally
1 parent 38aa4b3 commit aaf9087

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

src/plot_api/plot_api.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2399,6 +2399,8 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
23992399
for(i = 0; i < trans._frames.length; i++) {
24002400
frame = trans._frames[i];
24012401

2402+
if(!frame) continue;
2403+
24022404
if(allFrames || frame.group === frameOrGroupNameOrFrameList) {
24032405
frameList.push({
24042406
type: 'byname',
@@ -2561,7 +2563,7 @@ Plotly.addFrames = function(gd, frameList, indices) {
25612563
if(_hash[frame.name]) {
25622564
// If frame is present, overwrite its definition:
25632565
for(j = 0; j < _frames.length; j++) {
2564-
if(_frames[j].name === frame.name) break;
2566+
if((_frames[j] || {}).name === frame.name) break;
25652567
}
25662568
ops.push({type: 'replace', index: j, value: frame});
25672569
revops.unshift({type: 'replace', index: j, value: _frames[j]});

src/plots/plots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ plots.modifyFrames = function(gd, operations) {
14151415
break;*/
14161416
case 'replace':
14171417
frame = op.value;
1418-
var oldName = _frames[op.index].name;
1418+
var oldName = (_frames[op.index] || {}).name;
14191419
var newName = frame.name;
14201420
_frames[op.index] = _hash[newName] = frame;
14211421

test/jasmine/tests/animate_test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,3 +579,33 @@ describe('Test animate API', function() {
579579
});
580580
});
581581
});
582+
583+
describe('null frames', function() {
584+
'use strict';
585+
586+
var gd, mockCopy;
587+
588+
beforeEach(function(done) {
589+
gd = createGraphDiv();
590+
591+
mockCopy = Lib.extendDeep({}, mock);
592+
593+
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(function() {
594+
return Plotly.addFrames(gd, mockCopy.frames);
595+
}).then(done);
596+
});
597+
598+
afterEach(function() {
599+
Plotly.purge(gd);
600+
destroyGraphDiv();
601+
});
602+
603+
it('should not break everything', function(done) {
604+
gd._transitionData._frames.push(null);
605+
606+
Plotly.animate(gd, null, {
607+
frame: {duration: 0},
608+
transition: {duration: 0}
609+
}).catch(fail).then(done);
610+
});
611+
});

0 commit comments

Comments
 (0)