Zoomooz.js
Zoomooz is: 6KB gzipped and 18KB minified. This includes everything but jQuery.
Make any web page zoom.
Zoomooz is a jQuery plugin for making web page elements zoom. It can be used for making Prezi like slideshows and for zooming to images or other details.
Quirky transformations
You can zoom to elements that have been translated, scaled and skewed, and they will morph correctly.
Try by clicking on these:
There is some interesting stuff happening in the background to make the morphings work. To learn about them, read the Animate between complex transforms wiki page.
Adding Zoomooz to your web page
Just add this to your web page head and you should be up and running with Zoomooz:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="jquery.zoomooz.min.js"></script>
The easy way to zoom
Simply add "zoomTarget" to the element you want to zoom to when clicked on:
<div class="zoomTarget">This element zooms when clicked on.</div>
You can also add some additional attributes for tuning the animation as data fields of the element:
<div class="zoomTarget" data-targetsize="0.45" data-duration="600">This element zooms when clicked on.</div>
For documentation of the data fields, have a look at the Settings section.
Note, that adding Zoomooz to your existing web site without doing any markup changes might not work, since calculating exact positions and transformations in browsers is a bit of tricky.
Starting with one of zoomooz examples or an empty page with minimal css markup is easier to get working than to try to bolt zoomooz into an existing, complex web page.
Here is a demo, click on the elements:
By adding a "data-closeclick" value to a zoom target, you can make the image zoom out when the element is clicked for second time, see here:
(click twice)
(click twice)
(click twice)
Zooming inside a container
You can make only part of the page zoom by adding two blocks outside the zooming elements, a "zoomContainer" and outside it a "zoomViewport":
<div class="zoomViewport">
<div class="zoomContainer">
<div class="zoomTarget">Target 1</div>
<div class="zoomTarget">Target 2</div>
</div>
</div>
Here is a demo, click on the elements:
Adding prev/next buttons
You can also add previous and next buttons for zooming to elements in a specific order. You can use this to make slide shows, for example.
To do this, add "zoomButton" elements to control the animation:
<div class="zoomViewport demo">
<div class="zoomContainer">
<div class="zoomTarget">Target 1</div>
<div class="zoomTarget">Target 2</div>
</div>
</div>
<div class="zoomButton" data-type="prev" data-root=".demo"></div>
<div class="zoomButton" data-type="next" data-root=".demo"></div>
Here is a demo, try clicking on the arrow buttons:
Zooming jQuery way
To make an element zoom when clicked on, you can use "zoomTarget(...)":
$(document).ready(function() {
$("#element").zoomTarget();
});
This automatically makes also the parent element clickable for the user to be able to zoom back.
Another alternative is to handle the zooming yourself, with something like:
$(document).ready(function() {
$("#element").click(function(evt) {
$(this).zoomTo({targetsize:0.75, duration:600});
evt.stopPropagation();
});
});
This is more flexible, but won't give you all the automagical niceties, such as a nice pointer cursor when hovering over the element.
Settings
There are a number of settings you can add to the "zoomTarget" elements and pass to "zoomTo" functions in a map. The settings configure how the zooming behaves.
For elements with the "zoomTarget" class, you can set the settings by adding a "data-settingname" attribute to the element, for example:
<div class="zoomTarget" data-scalemode="width" data-nativeanimation="true">Click me</div>
List of all settings:
settings = {
// zoomed size relative to the container element
// 0.0-1.0
targetsize: 0.9,
// scale content to screen based on their size
// "width"|"height"|"both"
scalemode: "both",
// animation duration
duration: 450,
// easing of animation, similar to css transition params
// "linear"|"ease"|"ease-in"|"ease-out"|"ease-in-out"|[p1,p2,p3,p4]
// [p1,p2,p3,p4] refer to cubic-bezier curve params
easing: "ease",
// use browser native animation in webkit, provides faster and nicer
// animations but on some older machines, the content that is zoomed
// may show up as pixelated.
nativeanimation: true,
// root element to zoom relative to
// (this element needs to be positioned)
root: $(document.body),
// show debug points in element corners. helps
// at debugging when zoomooz positioning fails
debug: false,
// this function is called with the element that is zoomed to in this
// when animation ends
animationendcallback: null,
// this specifies, that clicking an element that is zoomed to zooms
// back out
closeclick: false,
// don't reset scroll before zooming. less jaggy zoom starts and ends on
// mobile browsers, but causes issues when zooming to elements when scrolled
// to a specific distance in document, typically around 2000px on webkit.
preservescroll: false
}
// settings can be set for both the zoomTo and zoomTarget calls:
$("#element").zoomTo(settings);
Browsers and platforms
Zoomooz works quite reliably on Firefox 3.6 or newer, on Safari 3 or newer and on recent versions of Chrome. Based on a quick test, seems to work fine on IE9 as well, but there may be bugs. Opera support has not been tested recently.
The only large group of users that is not supported at all is those still stuck with IE8. Luckily, the share of IE8 users is currently 11% and it is dropping quickly.
Zoomooz requires 1.4. or newer and has been tested with jQuery 1.9.
iPhone and iPad
Zoomooz works even on iPad and iPhone. Watch a video of Zoomooz on a first generation iPad.
Currently the zooming inside a container works much better on them than zooming the whole page. Whole page zooming can be made to work if "overflow:hidden" is set for the "html" and "body" elements, but then the page scrolling is lost.
Demos
Have a look at these:
Praise for Zoomooz
Here are some positive comments tweeted about Zoomooz:
The fantastic Javascript zooming library has been updated to work with Firefox 4.
— @azaaza
Really awesome example of a zoomable interface with JavaScript
— @tdhooper
Amazing little js library for zooming and rotating that works with JQuery
— @mike_j_edwards
#prezi like styles for your own website. damn cool and pretty easy
— @wollepb
Zoomooz in use
Some people have been brave enough to try out zoomooz themselves. Have a look at the links below and let me know if you have used it!
Very creative use of Zoomooz in this Frech presidential campaign web site
Aza Raskin prototyping with Zoomooz and showing how to live code in front of seventy-five people.
A photo gallery using Zoomooz for Antoine Giraldo.
A zooming comic experiment by Richard Milewski.
A virtual educational collage tool for classrooms that uses Zoomooz by Opinsys. Just create a new "pahvi", add some objects and browse in "presentation mode".
Simple HTML Slides by Richard Milewski uses Zoomooz.
A (slightly outdated) Zoomooz tutorial on Design Shack has a nice thumbnail gallery example.
Known issues & troubleshooting
Some known issues:
- Weird things happen when browser scrolls after zooming has happened. Should catch these and prevent.
- On iOs devices, zooming inside container sometimes freezes the scrolling. Haven't investigated what is causing this.
- Margins on zoomable elements can cause problems.
- Having a main container inside the body tag sometimes helps with full page zooming.
- Small text renders ugly. See this example for a hack to work around this.
- Rotation goes sometimes via the wrong direction.
Building
Easiest way to use Zoomooz is to use the pre-generated "jquery.zoomooz.min.js" file. However, you may also combine and minify the javascript files by yourself.
For build instructions, have a look at the Zoomooz github page.
Related Zooming projects
Impress.js by Bartosz Szopka is an interesting take on making Prezi like slides on the web. Harish Sivaramakrishnan has started to make an editor called Impressionist for Impress.js.
Jmpress.js is a jQuery port of Impress.js with some extra features.
Presenteer.js by Willem Mulder is also a bit similar to Impress.js and Zoomooz.
Another similar project is zoom.js by Hakim Elhattab, although it would seem to be currently mostly a proof of concept
A different approach to Zooming in ZUI53 library, using pinch zoom / scroll wheel.
The whole idea of zooming to content comes from a long line of user interface research related to zooming ui:s (ZUI:s). One starting point for these is the Zooming user interface Wikipedia page.
Other links
Zoomooz uses a smart easing that works the same way as css animation easings. If you'd like to use it with other jQuery animations, check out jquery.easie.js.