jquery 그림 확대 효과

주요 jquery 코드
 

  
  
  
  
  1. (function($){  
  2.     $.fn.preview = function(){  
  3.         var xOffset = 10;  
  4.         var yOffset = 20;  
  5.         var w = $(window).width();  
  6.         $(this).each(function(){  
  7.             $(this).hover(function(e){  
  8.                 if(/.png$|.gif$|.GIF$|.jpg$|.JPG$|.bmp$|.BMP$/.test($(this).attr("bigpic"))){  
  9.                     $("body").append("<div id='preview'><div><img src=\'#\'" /span>+$(this).attr('bigpic')+"' /><p>"+$(this).attr('title')+"</p></div></div>");  
  10.                 }else{  
  11.                     $("body").append("<div id='preview'><div><p>"+$(this).attr('title')+"</p></div></div>");  
  12.                 }  
  13.                 $("#preview").css({  
  14.                     position:"absolute",  
  15.                     padding:"4px",  
  16.                     border:"1px solid #f3f3f3",  
  17.                     backgroundColor:"#eeeeee",  
  18.                     top:(e.pageY - yOffset) + "px",  
  19.                     zIndex:1000  
  20.                 });  
  21.                 $("#preview > div").css({  
  22.                     padding:"5px",  
  23.                     backgroundColor:"white",  
  24.                     border:"1px solid #cccccc" 
  25.                 });  
  26.                 $("#preview > div > p").css({  
  27.                     textAlign:"center",  
  28.                     fontSize:"12px",  
  29.                     padding:"8px 0 3px",  
  30.                     margin:"0" 
  31.                 });  
  32.                 if(e.pageX < w/2){  
  33.                     $("#preview").css({  
  34.                         left: e.pageX + xOffset + "px",  
  35.                         right: "auto" 
  36.                     }).fadeIn("fast");  
  37.                 }else{  
  38.                     $("#preview").css("right",(w - e.pageX + yOffset) + "px").css("left""auto").fadeIn("fast");     
  39.                 }  
  40.             },function(){  
  41.                 $("#preview").remove();  
  42.             }).mousemove(function(e){  
  43.                 $("#preview").css("top",(e.pageY - xOffset) + "px")  
  44.                 if(e.pageX < w/2){  
  45.                     $("#preview").css("left",(e.pageX + yOffset) + "px").css("right","auto");  
  46.                 }else{  
  47.                     $("#preview").css("right",(w - e.pageX + yOffset) + "px").css("left","auto");  
  48.                 }  
  49.             });                         
  50.         });  
  51.     };  
  52. })(jQuery); 

2. html 코드
 

  
  
  
  
  1. <a class="preview" href="150.html" bigpic="http://show.icarlus.com//Upload/photos/4135314.jpg" title=" "><img src="http://show.icarlus.com//Upload/photos/4135314.jpg" /></a> 
  2.  <a class="preview" href="97.html" bigpic="http://show.icarlus.com//Upload/photos/419267.jpg" title=" "><img src="http://show.icarlus.com//Upload/photos/419267.jpg" /></a> 

좋은 웹페이지 즐겨찾기