@@ -107,7 +107,7 @@ Plotly.plot = function(gd, data, layout, config) {
107107
108108 // if the user is trying to drag the axes, allow new data and layout
109109 // to come in but don't allow a replot.
110- if ( gd . _dragging ) {
110+ if ( gd . _dragging && ! gd . _transitioning ) {
111111 // signal to drag handler that after everything else is done
112112 // we need to replot, because something has changed
113113 gd . _replotPending = true ;
@@ -235,6 +235,7 @@ Plotly.plot = function(gd, data, layout, config) {
235235 }
236236
237237 function doAutoRange ( ) {
238+ if ( gd . _transitioning ) return ;
238239 var axList = Plotly . Axes . list ( gd , '' , true ) ;
239240 for ( var i = 0 ; i < axList . length ; i ++ ) {
240241 Plotly . Axes . doAutoRange ( axList [ i ] ) ;
@@ -2597,6 +2598,8 @@ Plotly.transition = function(gd, data, layout, traceIndices, transitionConfig) {
25972598 doCalcdata ( gd ) ;
25982599
25992600 ErrorBars . calc ( gd ) ;
2601+
2602+ return Promise . resolve ( ) ;
26002603 }
26012604
26022605 function executeCallbacks ( list ) {
@@ -2618,6 +2621,16 @@ Plotly.transition = function(gd, data, layout, traceIndices, transitionConfig) {
26182621 var aborted = false ;
26192622
26202623 function executeTransitions ( ) {
2624+ // This flag is used to disabled things like autorange:
2625+ gd . _transitioning = true ;
2626+
2627+ // When instantaneous updates are coming through quickly, it's too much to simply disable
2628+ // all interaction, so store this flag so we can disambiguate whether mouse interactions
2629+ // should be fully disabled or not:
2630+ if ( transitionConfig . duration > 0 ) {
2631+ gd . _transitioningWithDuration = true ;
2632+ }
2633+
26212634 gd . _transitionData . _interruptCallbacks . push ( function ( ) {
26222635 aborted = true ;
26232636 } ) ;
@@ -2638,7 +2651,6 @@ Plotly.transition = function(gd, data, layout, traceIndices, transitionConfig) {
26382651 }
26392652
26402653 var traceTransitionConfig ;
2641- var hasTraceTransition = false ;
26422654 var j ;
26432655 var basePlotModules = fullLayout . _basePlotModules ;
26442656 var hasAxisTransition = false ;
@@ -2671,12 +2683,7 @@ Plotly.transition = function(gd, data, layout, traceIndices, transitionConfig) {
26712683 }
26722684
26732685 // If nothing else creates a callback, then this will trigger the completion in the next tick:
2674- setTimeout ( makeCallback ( ) ) ;
2675-
2676- if ( ! hasAxisTransition && ! hasTraceTransition ) {
2677- return false ;
2678- }
2679-
2686+ setTimeout ( makeCallback ( 'first' ) ) ;
26802687 }
26812688
26822689 function completeTransition ( ) {
@@ -2687,13 +2694,25 @@ Plotly.transition = function(gd, data, layout, traceIndices, transitionConfig) {
26872694 return Plotly . redraw ( gd ) ;
26882695 }
26892696 } ) . then ( function ( ) {
2697+ // Set transitioning false again once the redraw has occurred. This is used, for example,
2698+ // to prevent the trailing redraw from autoranging:
2699+ gd . _transitioning = false ;
2700+ gd . _transitioningWithDuration = false ;
2701+
26902702 gd . emit ( 'plotly_transitioned' , [ ] ) ;
26912703 } ) ;
26922704 }
26932705
26942706 function interruptPreviousTransitions ( ) {
26952707 gd . emit ( 'plotly_transitioninterrupted' , [ ] ) ;
26962708
2709+ // If a transition is interrupted, set this to false. At the moment, the only thing that would
2710+ // interrupt a transition is another transition, so that it will momentarily be set to true
2711+ // again, but this determines whether autorange or dragbox work, so it's for the sake of
2712+ // cleanliness:
2713+ gd . _transitioning = false ;
2714+ gd . _transtionWithDuration = false ;
2715+
26972716 return executeCallbacks ( gd . _transitionData . _interruptCallbacks ) ;
26982717 }
26992718
@@ -2715,11 +2734,12 @@ Plotly.transition = function(gd, data, layout, traceIndices, transitionConfig) {
27152734
27162735 var seq = [ Plots . previousPromises , interruptPreviousTransitions , prepareTransitions , executeTransitions ] ;
27172736
2718- var plotDone = Lib . syncOrAsync ( seq , gd ) ;
27192737
2720- if ( ! plotDone || ! plotDone . then ) plotDone = Promise . resolve ( ) ;
2738+ var transitionStarting = Lib . syncOrAsync ( seq , gd ) ;
27212739
2722- return plotDone . then ( function ( ) {
2740+ if ( ! transitionStarting || ! transitionStarting . then ) transitionStarting = Promise . resolve ( ) ;
2741+
2742+ return transitionStarting . then ( function ( ) {
27232743 gd . emit ( 'plotly_transitioning' , [ ] ) ;
27242744 return gd ;
27252745 } ) ;
0 commit comments