PDA

View Full Version : jQuery for Featured Image Zoomer



Mark_X
04-28-2012, 03:54 AM
1) Script Title: Featured Image Zoomer v1.5

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/featuredzoomer.htm

3) Describe problem:
Featured Image Zoomer works fine in jQuery1.4.4~1.6.4.
mouse can not be rollback small view in jQuery1.7.2(other plugin necessary),anyone could offer help?
I love this script,don't want remove it.
Thank you.

jscheuer1
04-28-2012, 10:30 AM
Looks like a bug in the later version of jQuery. They're not passing all of the required properties of the event in their version of the event object. Hopefully they'll fix that in a later update. In the meantime we can adapt featuredimagezoomer.js to the bug, because fortunately they do pass the original event object as a property of their version of it.

Using a text only editor like NotePad, open up the featuredimagezoomer.js file, find this function and add the highlighted:


magnifyimage: function($tracker, e, zoomrange){
if(!e.detail && !e.wheelDelta){e = e.originalEvent;}
var delta=e.detail? e.detail*(-120) : e.wheelDelta //delta returns +120 when wheel is scrolled up, -120 when scrolled down
var zoomdir=(delta<=-120)? "out" : "in"
var specs=$tracker.data('specs')
var magnifier=specs.magnifier, od=specs.imagesize, power=specs.curpower
var newpower=(zoomdir=="in")? Math.min(power+1, zoomrange[1]) : Math.max(power-1, zoomrange[0]) //get new power
var nd=[od.w*newpower, od.h*newpower] //calculate dimensions of new enlarged image within magnifier
magnifier.$image.css({width:nd[0], height:nd[1]})
specs.curpower=newpower //set current power to new power after magnification
specs.$statusdiv.html('Current Zoom: '+specs.curpower)
this.showstatusdiv(specs, 0, 500)
$tracker.trigger('mousemove')
},

BTW - I just checked and this is a known bug but the ticket on it shows the developers balking at fixing it while claiming it's not a bug, so claiming it's fixed. See:

http://bugs.jquery.com/ticket/10420

for more info.

Mark_X
04-29-2012, 06:53 AM
Thanks John!
I edit it well done. thank you very much! :)

BTW, a little bit question about trace zone can't keep in right position (overlay at border) sometimes.

Mark.

jscheuer1
04-29-2012, 02:03 PM
Other than get it away from the border, I'd have to see that to fix it.

If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.