Skip to content

Commit 7db7f03

Browse files
committed
Clean up slider positioning code
1 parent d2696e7 commit 7db7f03

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/components/sliders/draw.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,11 @@ function setActive(gd, sliderGroup, sliderOpts, index, doCallback, doTransition)
385385
if(!_step.method) return;
386386

387387
sliderOpts._invokingCommand = true;
388-
Plotly[_step.method](gd, args[0], args[1], args[2]).then(function() {
388+
389+
Plots.executeAPICommand(gd, _step.method, _step.args).then(function() {
389390
sliderOpts._invokingCommand = false;
390-
}, function() {
391+
}, function () {
391392
sliderOpts._invokingCommand = false;
392-
393-
// This is not a disaster. Some methods like `animate` reject if interrupted
394-
// and *should* nicely log a warning.
395-
Lib.warn('Warning: Plotly.' + _step.method + ' was called and rejected.');
396393
});
397394

398395
sliderGroup._nextMethod = null;
@@ -477,8 +474,12 @@ function setGripPosition(sliderGroup, sliderOpts, position, doTransition) {
477474

478475
var x = normalizedValueToPosition(sliderOpts, position);
479476

477+
// If this is true, then *this component* is already invoking its own command
478+
// and has triggered its own animation.
479+
if (sliderOpts._invokingCommand) return;
480+
480481
var el = grip;
481-
if(doTransition && sliderOpts.transition.duration > 0 && !sliderOpts._invokingCommand) {
482+
if(doTransition && sliderOpts.transition.duration > 0) {
482483
el = el.transition()
483484
.duration(sliderOpts.transition.duration)
484485
.ease(sliderOpts.transition.easing);

src/components/updatemenus/draw.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,7 @@ function drawButtons(gd, gHeader, gButton, menuOpts) {
301301
button.on('click', function() {
302302
setActive(gd, menuOpts, buttonOpts, gHeader, gButton, buttonIndex);
303303

304-
// call button method
305-
var args = buttonOpts.args;
306-
Plotly[buttonOpts.method](gd, args[0], args[1], args[2]);
304+
Plots.executeAPICommand(gd, buttonOpts.method, buttonOpts.args);
307305
});
308306

309307
button.on('mouseover', function() {

0 commit comments

Comments
 (0)