Skip to content
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

Clone target to support more cases #20

Merged
merged 12 commits into from
Sep 30, 2017
Merged

Conversation

francoischalifour
Copy link
Owner

@francoischalifour francoischalifour commented Sep 25, 2017

This is a brand new implementation of medium-zoom without any API changes.


This PR adds support for zooms in overflow: hidden containers (see #19, @antoinechalifour), but also for images having a transform property before being zoomed.

BeforeAfter

Why

  • Images in overflow: hidden containers stayed cropped when zoomed.
  • Images lose their initial transform properties once zoomed.

Solution

Clone the image and append it to the body so that it's not constraint to its parent or any of its previous properties. This clone needs to be at the exact same position as the original, without any transform property.

Steps

  1. Clone the target
  2. Position the clone with an absolute position
  3. Add the clone to the DOM on show event
  4. Hide the original target
  5. Animate the clone
  6. Animate the clone back to the original target position on hide event
  7. Show the original image and remove the clone from the DOM

Notes

Performance

I originally was concerned about performance, but we can still easily reach more than 60fps.

mz-clone-perf

Animation

Since we duplicate the target image, it can trigger some fancy animations. It's something we need to be aware of.

mz-oh-angle

Preview

View preview


This PR will also make possible the implementation of #6 🎉

@francoischalifour francoischalifour changed the title Clone target to support zooms in overflow: hidden containers Clone target to support more cases Sep 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant