MCPcopy Index your code
hub / github.com/plotly/plotly.js / setActive

Function setActive

src/components/sliders/draw.js:409–450  ·  view source on GitHub ↗
(gd, sliderGroup, sliderOpts, index, doCallback, doTransition)

Source from the content-addressed store, hash-verified

407}
408
409function setActive(gd, sliderGroup, sliderOpts, index, doCallback, doTransition) {
410 var previousActive = sliderOpts.active;
411 sliderOpts.active = index;
412
413 // due to templating, it's possible this slider doesn't even exist yet
414 arrayEditor(gd.layout, constants.name, sliderOpts)
415 .applyUpdate('active', index);
416
417 var step = sliderOpts.steps[sliderOpts.active];
418
419 sliderGroup.call(setGripPosition, sliderOpts, doTransition);
420 sliderGroup.call(drawCurrentValue, sliderOpts);
421
422 gd.emit('plotly_sliderchange', {
423 slider: sliderOpts,
424 step: sliderOpts.steps[sliderOpts.active],
425 interaction: doCallback,
426 previousActive: previousActive
427 });
428
429 if(step && step.method && doCallback) {
430 if(sliderGroup._nextMethod) {
431 // If we've already queued up an update, just overwrite it with the most recent:
432 sliderGroup._nextMethod.step = step;
433 sliderGroup._nextMethod.doCallback = doCallback;
434 sliderGroup._nextMethod.doTransition = doTransition;
435 } else {
436 sliderGroup._nextMethod = {step: step, doCallback: doCallback, doTransition: doTransition};
437 sliderGroup._nextMethodRaf = window.requestAnimationFrame(function() {
438 var _step = sliderGroup._nextMethod.step;
439 if(!_step.method) return;
440
441 if(_step.execute) {
442 Plots.executeAPICommand(gd, _step.method, _step.args);
443 }
444
445 sliderGroup._nextMethod = null;
446 sliderGroup._nextMethodRaf = null;
447 });
448 }
449 }
450}
451
452function attachGripEvents(item, gd, sliderGroup) {
453 if(gd._context.staticPlot) return;

Callers 2

draw.jsFile · 0.70
handleInputFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…