@@ -107,7 +107,7 @@ Plotly.plot = function(gd, data, layout, config) {
107
107
108
108
// if the user is trying to drag the axes, allow new data and layout
109
109
// to come in but don't allow a replot.
110
- if ( gd . _dragging ) {
110
+ if ( gd . _dragging && ! gd . _transitioning ) {
111
111
// signal to drag handler that after everything else is done
112
112
// we need to replot, because something has changed
113
113
gd . _replotPending = true ;
@@ -235,6 +235,7 @@ Plotly.plot = function(gd, data, layout, config) {
235
235
}
236
236
237
237
function doAutoRange ( ) {
238
+ if ( gd . _transitioning ) return ;
238
239
var axList = Plotly . Axes . list ( gd , '' , true ) ;
239
240
for ( var i = 0 ; i < axList . length ; i ++ ) {
240
241
Plotly . Axes . doAutoRange ( axList [ i ] ) ;
@@ -2597,6 +2598,8 @@ Plotly.transition = function(gd, data, layout, traceIndices, transitionConfig) {
2597
2598
doCalcdata ( gd ) ;
2598
2599
2599
2600
ErrorBars . calc ( gd ) ;
2601
+
2602
+ return Promise . resolve ( ) ;
2600
2603
}
2601
2604
2602
2605
function executeCallbacks ( list ) {
@@ -2618,6 +2621,16 @@ Plotly.transition = function(gd, data, layout, traceIndices, transitionConfig) {
2618
2621
var aborted = false ;
2619
2622
2620
2623
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
+
2621
2634
gd . _transitionData . _interruptCallbacks . push ( function ( ) {
2622
2635
aborted = true ;
2623
2636
} ) ;
@@ -2638,7 +2651,6 @@ Plotly.transition = function(gd, data, layout, traceIndices, transitionConfig) {
2638
2651
}
2639
2652
2640
2653
var traceTransitionConfig ;
2641
- var hasTraceTransition = false ;
2642
2654
var j ;
2643
2655
var basePlotModules = fullLayout . _basePlotModules ;
2644
2656
var hasAxisTransition = false ;
@@ -2671,12 +2683,7 @@ Plotly.transition = function(gd, data, layout, traceIndices, transitionConfig) {
2671
2683
}
2672
2684
2673
2685
// 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' ) ) ;
2680
2687
}
2681
2688
2682
2689
function completeTransition ( ) {
@@ -2687,13 +2694,25 @@ Plotly.transition = function(gd, data, layout, traceIndices, transitionConfig) {
2687
2694
return Plotly . redraw ( gd ) ;
2688
2695
}
2689
2696
} ) . 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
+
2690
2702
gd . emit ( 'plotly_transitioned' , [ ] ) ;
2691
2703
} ) ;
2692
2704
}
2693
2705
2694
2706
function interruptPreviousTransitions ( ) {
2695
2707
gd . emit ( 'plotly_transitioninterrupted' , [ ] ) ;
2696
2708
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
+
2697
2716
return executeCallbacks ( gd . _transitionData . _interruptCallbacks ) ;
2698
2717
}
2699
2718
@@ -2715,11 +2734,12 @@ Plotly.transition = function(gd, data, layout, traceIndices, transitionConfig) {
2715
2734
2716
2735
var seq = [ Plots . previousPromises , interruptPreviousTransitions , prepareTransitions , executeTransitions ] ;
2717
2736
2718
- var plotDone = Lib . syncOrAsync ( seq , gd ) ;
2719
2737
2720
- if ( ! plotDone || ! plotDone . then ) plotDone = Promise . resolve ( ) ;
2738
+ var transitionStarting = Lib . syncOrAsync ( seq , gd ) ;
2721
2739
2722
- return plotDone . then ( function ( ) {
2740
+ if ( ! transitionStarting || ! transitionStarting . then ) transitionStarting = Promise . resolve ( ) ;
2741
+
2742
+ return transitionStarting . then ( function ( ) {
2723
2743
gd . emit ( 'plotly_transitioning' , [ ] ) ;
2724
2744
return gd ;
2725
2745
} ) ;
0 commit comments