Results 1 to 7 of 7

Thread: jQuery Image Magnify v1.11 help

  1. #1
    Join Date
    Apr 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default jQuery Image Magnify v1.11 help

    1) Script Title: jQuery Image Magnify v1.11

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...agemagnify.htm

    3) Describe problem: How can i make the image magnify where the mouse is and not center to the page height ?

  2. #2
    Join Date
    Apr 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    how about having it display at the top on the web page

  3. #3
    Join Date
    Apr 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ok i found this that controls the image when you click on it.

    Code:
    var $clone=$target.clone().css({position:'absolute', visibility:'hidden', border:'1px solid gray', cursor:'pointer'}).appendTo(document.body)
    how to i change this to display at the top of the page

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Find this section in the code (starting at about line #54):

    Code:
    		$target.bind('click.magnify', function(e){ //action when original image is clicked on
    			var $this=$(this).css({opacity:setting.imgopacity})
    			var imageinfo=$this.data('imgshell')
    			jQuery.imageMagnify.refreshoffsets($(window), $this, imageinfo) //refresh offset positions of original and warped images
    			var $clone=imageinfo.$clone
    			$clone.stop().css({zIndex:++jQuery.imageMagnify.zIndexcounter, left:imageinfo.attrs.x, top:imageinfo.attrs.y, width:imageinfo.attrs.w, height:imageinfo.attrs.h, opacity:0, visibility:'visible', display:'block'})
    			.animate({opacity:1, left:0, top:0, width:imageinfo.newattrs.w, height:imageinfo.newattrs.h}, setting.duration,
    			function(){ //callback function after warping is complete
    				//none added		
    			}) //end animate
    		}) //end click
    See the highlighted line? Change both red values to 0 as shown. But if the page has scrolled, the larger image might not be seen once it gets to its destination.

    If you still want it to go where the mouse is, we could probably work out a formula for that using the e.pageX and e.pageY (I think that's what jQuery calls them) visa vis half the target dimensions of the fully enlarged image. However, that would in some cases probably put portions of the enlarged image outside of the user's window.

    I've gotta run right now. Try the above code modification first, just to see if it works.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Apr 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    that worked but how can i get it to the top of the window.

    so if i scroll down and click a pic it goes to the top of the page what about window.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Instead of 0 for the top: thinger use jQuery(window).scrollTop():

    Code:
    .animate({opacity:1, left:0, top:jQuery(window).scrollTop(), width:imageinfo.newattrs.w, height:imageinfo.newattrs.h}, setting.duration,
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Apr 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thank you

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •