163css.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*jqueryzoom&&jcarousel Download by http://down.liehuo.net*/
  2. (function($){
  3. $.fn.jqueryzoom=function(options){
  4. var settings={
  5. xzoom:200,
  6. yzoom:200,
  7. offset:10,
  8. position:"right",
  9. lens:1,
  10. preload:1};
  11. if(options){
  12. $.extend(settings,options);}
  13. var noalt='';
  14. $(this).hover(function(){
  15. var imageLeft=$(this).offset().left;
  16. var imageTop=$(this).offset().top;
  17. var imageWidth=$(this).children('img').get(0).offsetWidth;
  18. var imageHeight=$(this).children('img').get(0).offsetHeight;
  19. noalt=$(this).children("img").attr("alt");
  20. var bigimage=$(this).children("img").attr("jqimg");
  21. $(this).children("img").attr("alt",'');
  22. if($("div.zoomdiv").get().length==0){
  23. $(this).after("<div class='zoomdiv'><img class='bigimg' src='"+bigimage+"'/></div>");
  24. $(this).append("<div class='jqZoomPup'>&nbsp;</div>");}
  25. if(settings.position=="right"){
  26. if(imageLeft+imageWidth+settings.offset+settings.xzoom>screen.width){
  27. leftpos=imageLeft-settings.offset-settings.xzoom;}else{
  28. leftpos=imageLeft+imageWidth+settings.offset;}}else{
  29. leftpos=imageLeft-settings.xzoom-settings.offset;
  30. if(leftpos<0){
  31. leftpos=imageLeft+imageWidth+settings.offset;}}
  32. $("div.zoomdiv").css({top:imageTop,left:leftpos});
  33. $("div.zoomdiv").width(settings.xzoom);
  34. $("div.zoomdiv").height(settings.yzoom);
  35. $("div.zoomdiv").show();
  36. if(!settings.lens){
  37. $(this).css('cursor','crosshair');}
  38. $(document.body).mousemove(function(e){
  39. mouse=new MouseEvent(e);
  40. var bigwidth=$(".bigimg").get(0).offsetWidth;
  41. var bigheight=$(".bigimg").get(0).offsetHeight;
  42. var scaley='x';
  43. var scalex='y';
  44. if(isNaN(scalex)|isNaN(scaley)){
  45. var scalex=(bigwidth/imageWidth);
  46. var scaley=(bigheight/imageHeight);
  47. $("div.jqZoomPup").width((settings.xzoom)/(scalex*1));
  48. $("div.jqZoomPup").height((settings.yzoom)/(scaley*1));
  49. if(settings.lens){
  50. $("div.jqZoomPup").css('visibility','visible');}}
  51. xpos=mouse.x-$("div.jqZoomPup").width()/2-imageLeft;
  52. ypos=mouse.y-$("div.jqZoomPup").height()/2-imageTop;
  53. if(settings.lens){
  54. xpos=(mouse.x-$("div.jqZoomPup").width()/2 < imageLeft ) ? 0 : (mouse.x + $("div.jqZoomPup").width()/2>imageWidth+imageLeft)?(imageWidth-$("div.jqZoomPup").width()-2):xpos;
  55. ypos=(mouse.y-$("div.jqZoomPup").height()/2 < imageTop ) ? 0 : (mouse.y + $("div.jqZoomPup").height()/2>imageHeight+imageTop)?(imageHeight-$("div.jqZoomPup").height()-2):ypos;}
  56. if(settings.lens){
  57. $("div.jqZoomPup").css({top:ypos,left:xpos});}
  58. scrolly=ypos;
  59. $("div.zoomdiv").get(0).scrollTop=scrolly*scaley;
  60. scrollx=xpos;
  61. $("div.zoomdiv").get(0).scrollLeft=(scrollx)*scalex;});},function(){
  62. $(this).children("img").attr("alt",noalt);
  63. $(document.body).unbind("mousemove");
  64. if(settings.lens){
  65. $("div.jqZoomPup").remove();}
  66. $("div.zoomdiv").remove();});
  67. count=0;
  68. if(settings.preload){
  69. $('body').append("<div style='display:none;' class='jqPreload"+count+"'>360buy</div>");
  70. $(this).each(function(){
  71. var imagetopreload=$(this).children("img").attr("jqimg");
  72. var content=jQuery('div.jqPreload'+count+'').html();
  73. jQuery('div.jqPreload'+count+'').html(content+'<img src=\"'+imagetopreload+'\">');});}}})(jQuery);
  74. function MouseEvent(e){
  75. this.x=e.pageX;
  76. this.y=e.pageY;}