-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Set key function for layout images #7277
Conversation
Hmph I guess we DO have image animation? Investigating the test failure... |
@@ -106,7 +106,7 @@ describe('Plots.transition', function() { | |||
var pythonLogo = 'https://images.plot.ly/language-icons/api-home/python-logo.png'; | |||
|
|||
function imageel() { | |||
return gd._fullLayout._imageUpperLayer.select('image').node(); |
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.
I wasn't able to replicate the transition error on real code so started poking around the test itself. I don't understand it, but somehow doing this d3 selection was resetting the data stored with the image element, causing the key function I added in this PR to think the existing element wasn't the right one to use for the new image, so line 135 below expect(e1).toBe(e2);
failed. Switching to a native JS querySelector
fixed it. 🤷
Thanks very much for the PR. |
Continuing my quest to make
layout.images
work well for a custom tile server - panning around is currently glitchy, because when new tiles are added at or removed from the beginning of the array, we first shift the existing images to where the new start is, then update the URLs.This PR changes it so if there's an image at the same data or paper coordinates we'll leave the same element there, create new elements at new coordinates, and delete elements at coordinates where there is no longer an image. Two caveats to be aware of, but I think these are reasonable:
id
and have that override this coordinate-based key. That would likely be necessary if we wanted to enable image animation, but we don't have that today.id
attribute.