-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Layout animations for container array'd objects #1081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
891af3b
Change layout update to use new logic
rreusser 726cbf0
Slightly improve transition redraw/interrupt behavior
rreusser b20371c
The linter, again
rreusser c137464
Add test for annotations actually moving
rreusser 2bcc266
Add test for annotations actually moving
rreusser 63cd19b
Merge branch 'annotation-animation' of github.com:plotly/plotly.js in…
rreusser 03d19bc
Tweak images to handle animation a bit better
rreusser 30929dc
Test that shapes are updated by transitions
rreusser b72e36d
Test more attributes of shape transitions on redraw
rreusser 43b95d8
Swap image source
rreusser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1418,6 +1418,8 @@ plots.extendObjectWithContainers = function(dest, src, containerPaths) { | |
for(j = 0; j < srcContainer.length; j++) { | ||
destContainer[j] = plots.extendObjectWithContainers(destContainer[j], srcContainer[j]); | ||
} | ||
|
||
destProp.set(destContainer); | ||
} | ||
} | ||
|
||
|
@@ -1510,7 +1512,7 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts) | |
delete layoutUpdate[attr].range; | ||
} | ||
|
||
Lib.extendDeepNoArrays(gd.layout, layoutUpdate); | ||
plots.extendLayout(gd.layout, layoutUpdate); | ||
|
||
// Supply defaults after applying the incoming properties. Note that any attempt | ||
// to simplify this step and reduce the amount of work resulted in the reconstruction | ||
|
@@ -1556,10 +1558,25 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts) | |
gd._transitioningWithDuration = true; | ||
} | ||
|
||
|
||
// If another transition is triggered, this callback will be executed simply because it's | ||
// in the interruptCallbacks queue. If this transition completes, it will instead flush | ||
// that queue and forget about this callback. | ||
gd._transitionData._interruptCallbacks.push(function() { | ||
aborted = true; | ||
}); | ||
|
||
if(frameOpts.redraw) { | ||
gd._transitionData._interruptCallbacks.push(function() { | ||
return Plotly.redraw(gd); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice use of |
||
}); | ||
} | ||
|
||
// Emit this and make sure it happens last: | ||
gd._transitionData._interruptCallbacks.push(function() { | ||
gd.emit('plotly_transitioninterrupted', []); | ||
}); | ||
|
||
// Construct callbacks that are executed on transition end. This ensures the d3 transitions | ||
// are *complete* before anything else is done. | ||
var numCallbacks = 0; | ||
|
@@ -1631,14 +1648,11 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts) | |
} | ||
|
||
function interruptPreviousTransitions() { | ||
gd.emit('plotly_transitioninterrupted', []); | ||
|
||
// If a transition is interrupted, set this to false. At the moment, the only thing that would | ||
// interrupt a transition is another transition, so that it will momentarily be set to true | ||
// again, but this determines whether autorange or dragbox work, so it's for the sake of | ||
// cleanliness: | ||
gd._transitioning = false; | ||
gd._transtionWithDuration = false; | ||
|
||
return executeCallbacks(gd._transitionData._interruptCallbacks); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,34 @@ function runTests(transitionDuration) { | |
}).catch(fail).then(done); | ||
}); | ||
|
||
it('transitions an annotation', function(done) { | ||
function annotationPosition() { | ||
var g = gd._fullLayout._infolayer.select('.annotation').select('.annotation-text-g'); | ||
return [parseInt(g.attr('x')), parseInt(g.attr('y'))]; | ||
} | ||
var p1, p2; | ||
|
||
Plotly.relayout(gd, {annotations: [{x: 0, y: 0, text: 'test'}]}).then(function() { | ||
p1 = annotationPosition(); | ||
|
||
return Plots.transition(gd, null, { | ||
'annotations[0].x': 1, | ||
'annotations[0].y': 1 | ||
}, [], | ||
{redraw: true, duration: transitionDuration}, | ||
{duration: transitionDuration, easing: 'cubic-in-out'} | ||
); | ||
}).then(function() { | ||
p2 = annotationPosition(); | ||
|
||
// Ensure both coordinates have moved, i.e. that the annotation has transitioned: | ||
expect(p1[0]).not.toEqual(p2[0]); | ||
expect(p1[1]).not.toEqual(p2[1]); | ||
|
||
}).catch(fail).then(done); | ||
|
||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
|
||
it('transitions a transform', function(done) { | ||
Plotly.restyle(gd, { | ||
'transforms[0]': { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, this now guarantees that
shapes
,images
and all the other layout array container can also be animated?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless there are bugs, yes. It iterates through each of those container arrays as a way of bypassing the
No
inextendDeepNoArrays
. The option to force redraw makes non-animatable things Just Work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Let's 🔒 this down by expanding test case
https://github.com/plotly/plotly.js/pull/1081/files#diff-2032f9a39fb6bbc9611ed5ec74c10c19R68
to transition all layout array containers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lunch, then adding it.