drop-in zoomer for anything
Zoom in, zoom out on (almost) anything in your page.
Include with a script tag, or install with your package manager of choice (Bower/Component/npm).
Now when you click on
#my-image, it will... of course, zoom in. When you click again, it will zoom back out to its original place. (get it?)
This is largely inspired by Medium's avatar zoom in effect, with improvements (you can resize / scroll the page when it's zoomed in and it still works). Please note it depends on the way browsers handle CSS transforms and has limited compatibility.
Attach click listeners to all matched elements. You can also directly pass in a single node to this method.
Zoom in on the matched element. Fires optional callback when the transition is done.
Zoom out if currently zoomed-in. Fires optional callback when the transition is done.
Takes an options object. Available options (all options take valid CSS values):
maxWidth- max element width when zoomed-in. default:
maxHeight- max element height when zoomed-in. default:
deepCopy- whether to copy innerHTML. If target element has complicated inner structure you might need this to make it work. default:
onOpen- a callback function that will be called when a target is zoomed in and transition has ended. It will get the target element as the argument.
onClose- same as
onOpen, except fired when zoomed out.
Brought to you by @youyuxi.