MooTools Zoomer Plugin

By  on  

MooTools Image Zoom

I love to look around the MooTools Forge. As someone that creates lots of plugins, I get a lot of joy out of seeing what other developers are creating and possibly even how I could improve them. One great plugin I've found is Zoomer by Anton Samoylov. Zoomer provides an elegant method for zooming in on large images.

The HTML

<img src="cricci.jpg" alt="Muse: Christina Ricci" big="cricci-large.jpg" id="ricci" />

Note the big attribute within the image is where the you place the path to the larger image. This is the default usage of the plugin -- you may also provide the path to the larger image within the plugin instance options object.

The MooTools JavaScript

window.addEvent('domready',function() {
	new Zoomer('ricci',{ 
		smooth: 10/*,
		big: 'cricci-large.jpg' */
	});
});

Using Zoomer is as easy as the code above -- simply provide the ID of the image and the custom smooth setting. As mentioned above, you may also define the larger image path within the instance.

Sweet huh? My praise goes out to Anton for his excellent plugin. I love how easy this plugin is to implement. Remember though -- Zoomer is just one of hundreds of quality plugins in the MooTools Forge. Are your plugins in the Forge?

Recent Features

Incredible Demos

  • By
    Introducing MooTools ElementSpy

    One part of MooTools I love is the ease of implementing events within classes. Just add Events to your Implements array and you can fire events anywhere you want -- these events are extremely helpful. ScrollSpy and many other popular MooTools plugins would...

  • By
    MooTools Gone Wild: Element Flashing

    If you're like me and lay awake in bed at night, you've flipped on the TV and seen the commercials: misguided, attention-starved college girls fueled by alcohol ruining their futures by flashing lame camera-men on Spring Break. Why do they do it? Attention...

Discussion

  1. doxe

    Great & useful plugin !
    Is there any chance to have an equivalent plugin working with jQuery ?

  2. Thats really neat!

  3. very very neat, nice fade effect when you mouseout. Nice Anton Samoylov and DW, MT FTW!

  4. very nice effect

  5. Awesome indeed!

  6. olivier

    Nice, I like this effect much better than the usual zoom effect with a small zoom box on top the the original image

  7. deef

    smooth effect, though I think you should be adding a CR-category by now…

  8. hamburger

    Hello David,
    thats really gorgeous.
    May be you can show us how this works with your nina ricci slide-show.

  9. way to go…. I must want to include/use it on my photography site

  10. quote doxe, exist plug-in jquery? :)

  11. Hello David,

    Nice script!

    Just a tiny comment on mouse events :)

    From usability point of view, i believe it will be better to disable click and drag when you mouse over to zoom.

    Usually people are not getting into the meaning of new type of cursor, so they click and often click and drag.

    In you script when you mouse over and click, so the thumb appears over the large(zoomed) image.

    Here is a screen-shot http://i.imgur.com/PSjLJ.jpg

    I believe what you have created is greater than what i have written here and it’s maybe not important but it’s definitely usable.

    T4A
    Keep up the good work!

  12. @moro: hi, work with mozilla firefox, don’t work with internet explorer 7 :(

  13. fixed ________________

  14. thanks :) very good work!!

  15. hnal

    Hi there, is there a way to change the big image via javascript ? I’m trying to build a gallery with the picture+zoom capabilities and thumbnails. But I can only change the src picture.

    This is not working :

    function changepics(ref)
    	{
    
    	document.getElementById('zoom').src = ref;
    	document.getElementById('zoom').setAttribute('big',ref);
    	new Zoomer('zoom',  {big: ref ,smooth: 10});
    	}
    

    thanks,
    hnal

  16. Samarjit Sen

    Very cool and attactive

  17. Samarjit Sen

    Very cool and effective

  18. luki

    @hnal:

    I have same problem… Have you found solution?

  19. hnal

    @luki:

    Hello, i’m still stuck with that issue. Nom i’m trying to reload the entire page when someone click on a thumbnail..

    And you ?

    • it’s my way. Hope will get help.
      1. keep the reference of the Zoomer instance.

      var imgZoom =  new Zoomer('mainImage');
      

      2.when you want to change the big picture, do this.

      imgZoom.big.set('src','path of your new big picture');
    • hnal

      Thanks for the reply! I tried your solution but I couldn’t make it work! Do you have a full exemple where it is working?

  20. guest

    great plugin!!!
    Could you change a picture for demo?
    It scare me… …

    • Try this:

      var imgZoom = new Zoomer('mainImage');
      imgZoom.big.set('src','path of your new big picture');
  21. Have an problem with this plugin, i work on rails 2.3.8 and this plugin re-submit the current page with id => ” _” … And cause an Active RecordNotFound :-/

  22. I also have similar problem, when using with prettyphoto – jquery lightbox alternative, background set as (_), applied in inline style causing problem, error and zooming doesn’t work at all.

    Pls check at this url:
    http://projects.xcellence-it.com/rahulraj-prettyphoto-zoomer/

    And mouse hover on first/top project box, which will open slider, and click on Location Plan. This open iframe where zoomer is implemented.

    Zooming sometimes work and sometimes not in FF.

    And in IE, it works only for the first time.

    Please help us how to fix this…

    Regards
    Krunal

  23. Just an update that I’m not using Rail. Mine was only pure xhtml project. But this has caused error and hence zoomer doesn’t work when using prettyphoto iframe.

  24. Martin

    very nice. would that also work with image maps in the larger image?

  25. michaela

    Hi!

    Very nice! I like it!

    And so I’ve used it!

    But somehow it’s not working properly:
    In Mozilla Firefox it’s perfect but on IE only when viewed on my PC at home. When I upload it on the server and look at it with IE, the enlarged picture is vertically twisted.

    I have no idea why???

    I’m thankfull for any ideas

  26. Kasimir

    Perhaps worth noting: the Zoomer plugin does not work 100% with the latest MooTools 1.3 release (I’ve tried with Zoomer 1.9.3., which is the newest I could find).
    However, the fix for this is tiny:

    Line 149:
    $clear(this.timer);

    should be:

    clearTimeout(this.timer);

    $clear has been deprecated, causing the stopZoom function to stop working, therefore the picture stayed zoomed.

  27. Alpinyo

    Hy David!
    Is there a way to have multiple images with zoom on one page without to have for every id or every new image a nev zoomer ? Just one class for every image.
    ex.

    new Zoomer('.multipleimg');

    Thanks

    • Alpinyo

      Sorry!
      I am new so I wraped in :) the

    • Alpinyo

      Hy David!

      Is there a way to have multiple images with zoom on one page without to have for every id or every new image a nev zoomer ? Just one class for every image.
      ex.

      new Zoomer(‘.multipleimg’);

      img src=img1.jpg class=multipleimg big=img1big.jpg

      img src=img2.jpg class=brainstorm big=img2big.jpg

      etc…….
      Thanks again

      Sorry, I am posting again. I am new so please forgive my clumsiness. Maybe you could delete my older posts.

  28. ony image – one zoomer, iterate and create new Zoomer for each image.

    • Alpinyo

      Is there a way to iterate the java script code automatically every time a new image is added? (for the sake of easiness)

  29. Zenka

    Hello,

    i’am french, Greatulation for this script.
    I have a question please.

    It’s possible of change “id=”ricci” by the class=”ricci” ?

    i have a error her ==>

    initialize: function(element, options){
    this.setOptions(options);
    this.small = document.id(element);

    document.id .

    Please what the code for a class ?

    Thanks

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!