index.html 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="author" content="yihu.com" />
  6. <meta name="format-detection" content="telephone=no" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  8. <meta name="apple-mobile-web-app-capable" content="yes" />
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  10. <title>图片放大缩小</title>
  11. <link rel="stylesheet" href="../../css/cross.css" type="text/css" />
  12. <link rel="stylesheet" href="../../css/demo.css" type="text/css" />
  13. <link rel="stylesheet" href="../artDialog/4.1.7/css/artDialog.css" type="text/css" />
  14. <style>
  15. #pageContent {width: 980px; height: 500px;overflow: hidden;position:relative;margin:50px auto;}
  16. #imgContainer {width: 980px;height: 500px;}
  17. #positionButtonDiv {background: rgb(58, 56, 63);background: rgba(58, 56, 63, 0.8);border: solid 1px #100000;color: #fff;padding: 8px;text-align: left;position: absolute;right:35px;top:35px;}
  18. .zoomButton {border: 0; cursor: pointer;}
  19. </style>
  20. </head>
  21. <body>
  22. <div class="demo-wrap c-main">
  23. <h2 class="demo-title c-f16">图片放大缩小 DEMO</h2>
  24. <div id="esmartzoom">
  25. <ul class="c-blocks-6">
  26. <li data-img="images/demo/200881211331729_2.jpg"><img src="images/demo/200881211331729_2.jpg" style="width:100px; height:100px;" /></li>
  27. <li data-img="images/demo/zoomFullScreen.jpg"><img src="images/demo/zoomFullScreen.jpg" style="width:100px; height:100px;" /></li>
  28. <li data-img="images/demo/2722-12033109302882.jpg"><img src="images/demo/2722-12033109302882.jpg" style="width:100px; height:100px;" /></li>
  29. <li data-img="images/demo/200711912453162_2.jpg"><img src="images/demo/200711912453162_2.jpg" style="width:100px; height:100px;" /></li>
  30. <li data-img="images/demo/2007119124413448_2.jpg"><img src="images/demo/2007119124413448_2.jpg" style="width:100px; height:100px;" /></li>
  31. <li data-img="images/demo/200881211331729_2.jpg"><img src="images/demo/200881211331729_2.jpg" style="width:100px; height:100px;" /></li>
  32. </ul>
  33. </div>
  34. </div>
  35. <!--代码部分begin-->
  36. <div id="pageContent" class="c-position-r">
  37. <div id="imgContainer">
  38. <img id="imageFullScreen" src="images/demo/200881211331729_2.jpg"/>
  39. </div>
  40. <div id="positionButtonDiv" class="c-position-a">
  41. <p>
  42. <span>
  43. <img id="zoomInButton" class="zoomButton" src="images/zoomIn.png" title="放大" alt="放大" />
  44. <img id="zoomOutButton" class="zoomButton" src="images/zoomOut.png" title="缩小" alt="缩小" />
  45. <img id="zoomPrevButton" class="zoomButton" src="images/left.png" title="上一张" alt="上一张" />
  46. <img id="zoomNextButton" class="zoomButton" src="images/right.png" title="下一张" alt="下一张" />
  47. <img id="zoomCloseButton" class="zoomButton" src="images/close.png" title="关闭" alt="关闭" />
  48. </span>
  49. </p>
  50. </div>
  51. </div>
  52. <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
  53. <script src="../../../../widget/artDialog/4.1.7/js/artDialog.js"></script>
  54. <script src="js/esmartzoom.js"></script>
  55. <script>
  56. $(document).ready(function() {
  57. var index=0,length=$('#esmartzoom ul li').length;
  58. $('#imageFullScreen').smartZoom({'containerClass':'zoomableContainer'});
  59. $('#zoomInButton,#zoomOutButton').bind("click", zoomButtonClickHandler);
  60. $('#zoomPrevButton,#zoomNextButton').bind("click", zoomButtonClickPic);
  61. function zoomButtonClickPic(e){
  62. if(e.target.id == 'zoomPrevButton'){
  63. if(index==0){return false;}
  64. index--;
  65. }else{
  66. if(index>=length){return false;}
  67. index++;
  68. }
  69. $('#imageFullScreen').attr('src',$('#esmartzoom ul li').eq(index).data('img'));
  70. //$('#imageFullScreen').smartZoom({'containerClass':'zoomableContainer'});
  71. }
  72. function zoomButtonClickHandler(e){
  73. var scaleToAdd = 0.8;
  74. if(e.target.id == 'zoomOutButton')
  75. scaleToAdd = -scaleToAdd;
  76. $('#imageFullScreen').smartZoom('zoom', scaleToAdd);
  77. }
  78. });
  79. </script>
  80. <!--代码部分end-->
  81. </body>
  82. </html>