3

I'm using the jQuery plugin Cloud Zoom, and I've altered the initialization so that the image is zoomed when the user clicks on a "magnify button" instead of hovering. I'm not sure how to unset/remove this event when the user leaves the image though, and I'd be very interested to hear what the best practice would be.

This is what the script looks like -

$('.magnify').click(function() {
    $('.cloud-zoom').CloudZoom({ showTitle: false });
    return false;
});

$('.display').mouseout(function() {
  // unset?
});

(".display" is a container) Is bind/unbind necessary? It seems it might do the trick, but I wish there was an easier method since it's just about one function.

4

3 回答 3

6

Simply use the destroy function of CloudZoom:

$('.cloud-zoom').data('zoom').destroy();

Note that this destroys only the first occurence, if you have more than one use:

$('.cloud-zoom').each(function(){
  $(this).data('zoom').destroy();
});
于 2011-10-31T19:40:21.340 回答
5

For the Star Plugins version 3 it is

$('.cloudzoom').data('CloudZoom').destroy();
于 2013-02-27T20:00:44.367 回答
0

So you are trying to "remove" the zoomed image when you mouseout? That seems to be a bit of an accessibility issue. Also, what if you lose track of your mouse, so that mean the zoom will leave if you shake your mouse a bit and accidentally leave the display? Seems a bit clunky. Why not have something like when you click elsewhere besides the image?

于 2011-10-31T20:03:52.400 回答