jQuery支持鼠标滚轮缩放以及点击按钮缩放图片插件
XML/HTML Code
- <div class="mkeContentBox">
- <!--效果html开始-->
- <div id="pageContent">
- <div id="imgContainer"><div id="smartZoomContainer1468760257884" class="zoomableContainer" style="overflow: hidden; position: relative; top: 0px; left: 0px; width: 980px; height: 610px;"><img id="imageFullScreen" src="images/webImg.jpg" style="visibility: visible; cursor: move; transform-origin: 0px 0px 0px; transition: all 0s ease-out; transform: translate3d(-2033.12px, -1115.82px, 0px) scale3d(2.33971, 2.33971, 1);"></div></div>
- <div id="positionButtonDiv">
- <p>
- <span>
- <img id="zoomInButton" class="zoomButton" src="images/zoomIn.png" title="zoom in" alt="zoom in">
- <img id="zoomOutButton" class="zoomButton" src="images/zoomOut.png" title="zoom out" alt="zoom out">
- </span>
- </p>
- <p><span class="positionButtonSpan">
- <map name="positionMap" class="positionMapClass">
- <area id="topPositionMap" shape="rect" coords="20,0,40,20" title="move up" alt="move up">
- <area id="leftPositionMap" shape="rect" coords="0,20,20,40" title="move left" alt="move left">
- <area id="rightPositionMap" shape="rect" coords="40,20,60,40" title="move right" alt="move right">
- <area id="bottomPositionMap" shape="rect" coords="20,40,40,60" title="move bottom" alt="move bottom">
- </map>
- <img src="images/position.png" usemap="#positionMap"> </span> </p>
- </div>
- </div>
- <!--效果html结束-->
- </div>
JavaScript Code
- <script>
- $(document).ready(function() {
- $('#imageFullScreen').smartZoom({'containerClass':'zoomableContainer'});
- $('#topPositionMap,#leftPositionMap,#rightPositionMap,#bottomPositionMap').bind("click", moveButtonClickHandler);
- $('#zoomInButton,#zoomOutButton').bind("click", zoomButtonClickHandler);
- function zoomButtonClickHandler(e){
- var scaleToAdd = 0.4;
- if(e.target.id == 'zoomOutButton')
- scaleToAdd = -scaleToAdd;
- $('#imageFullScreen').smartZoom('zoom', scaleToAdd);
- }
- function moveButtonClickHandler(e){
- var pixelsToMoveOnX = 0;
- var pixelsToMoveOnY = 0;
- switch(e.target.id){
- case "leftPositionMap":
- pixelsToMoveOnX = 200;
- break;
- case "rightPositionMap":
- pixelsToMoveOnX = -200;
- break;
- case "topPositionMap":
- pixelsToMoveOnY = 200;
- break;
- case "bottomPositionMap":
- pixelsToMoveOnY = -200;
- break;
- }
- $('#imageFullScreen').smartZoom('pan', pixelsToMoveOnX, pixelsToMoveOnY);
- }
- });
- </script>
原文地址:http://www.freejs.net/article_jquerytupiantexiao_689.html