• 图片点击放大插件


    最近因为需要找了个图片点击放大的插件,感觉还行吧~~

    底下给香瓜文件下载参考↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    如图

    接下来放香瓜代码:

    主要用到下面的样式文件和js文件

    <link rel="stylesheet" href="css/viewer.min.css" /> <script type="text/javascript" src="js/viewer.min.js"> <script type="text/javascript"> $(".honor_ul").viewer(); </script>

    香瓜html代码:

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>Test</title>
        <meta name="keywords" content="test">
        <meta name="description" content="test">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
     
        <link rel="stylesheet" type="text/css" href="css/slick.css" />
        <link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
        <link rel="stylesheet" type="text/css" href="css/jquery.mmenu.all.css" />
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <link rel="stylesheet" type="text/css" href="css/reset.css" />
        <link rel="stylesheet" href="css/viewer.min.css" />
    
    </head>
    <body>
        <div>
            <h1 style="margin:auto 0;text-align:center;color:#0094ff;font-size:38px;">图片点击放大</h1>
            <div class="com_zi clearfix">
               
                <div class="right_zi">
                   
                    <ul class="honor_ul clearfix">
                        <li>
                            <div class="pic">
                                <img src="images/fd/f1.jpg" alt="" class="vcenter" />
                                <i></i>
                            </div>
                            <p>嘤嘤嘤</p>
                        </li>
                        <li>
                            <div class="pic">
                                <img src="images/fd/f1.jpg" alt="" class="vcenter" />
                                <i></i>
                            </div>
                            <p>嘤嘤嘤</p>
                        </li>
                        <li>
                            <div class="pic">
                                <img src="images/fd/f1.jpg" alt="" class="vcenter" />
                                <i></i>
                            </div>
                            <p>嘤嘤嘤</p>
                        </li>
                        <li>
                            <div class="pic">
                                <img src="images/fd/f1.jpg" alt="" class="vcenter" />
                                <i></i>
                            </div>
                            <p>嘤嘤嘤</p>
                        </li>
                        <li>
                            <div class="pic">
                                <img src="images/fd/f1.jpg" alt="" class="vcenter" />
                                <i></i>
                            </div>
                            <p>嘤嘤嘤</p>
                        </li>
                        <li>
                            <div class="pic">
                                <img src="images/fd/f1.jpg" alt="" class="vcenter" />
                                <i></i>
                            </div>
                            <p>嘤嘤嘤</p>
                        </li>
                        <li>
                            <div class="pic">
                                <img src="images/fd/f1.jpg" alt="" class="vcenter" />
                                <i></i>
                            </div>
                            <p>嘤嘤嘤</p>
                        </li>
                        <li>
                            <div class="pic">
                                <img src="images/fd/f1.jpg" alt="" class="vcenter" />
                                <i></i>
                            </div>
                            <p>嘤嘤嘤</p>
                        </li>
                        <li>
                            <div class="pic">
                                <img src="images/fd/f1.jpg" alt="" class="vcenter" />
                                <i></i>
                            </div>
                            <p>嘤嘤嘤</p>
                        </li>
                    </ul>
    
                </div>
            </div>
         
        </div>
        <!--Include Js-->
        <script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/jquery.mmenu.all.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/public.js" type="text/javascript" charset="utf-8"></script>
        <!--slick-->
        <script src="js/slick.min.js" type="text/javascript" charset="utf-8"></script>
    <!--主要js文件--> <script type="text/javascript" src="js/viewer.min.js"> </script> <script type="text/javascript"> $(function () { $('.banner').slick({ dots: true, autoplay: true, arrows: false, autoplaySpeed: 3000, }); }); </script> <!--placeholder--> <script src="js/jquery.placeholder.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> $(function () { $('input, textarea').placeholder(); }); </script> <script type="text/javascript"> $(".honor_ul").viewer(); </script> </body> </html>

    js文件:

    viewer.min.js

    /*!
     * Viewer v0.1.0
     * https://github.com/fengyuanchen/viewer
     *
     * Copyright (c) 2015 Fengyuan Chen
     * Released under the MIT license
     *
     * Date: 2015-09-02T09:08:17.666Z
     */
    !function(i){"function"==typeof define&&define.amd?define("viewer",["jquery"],i):i("object"==typeof exports?require("jquery"):jQuery)}(function(i){"use strict";function t(i){return"string"==typeof i}function e(i){return"number"==typeof i&&!isNaN(i)}function s(i){return"undefined"==typeof i}function n(i,t){var s=[];return e(t)&&s.push(t),s.slice.apply(i,s)}function a(i,t){var e=n(arguments,2);return function(){return i.apply(t,e.concat(n(arguments)))}}function o(i){var t=[],s=i.rotate,n=i.scaleX,a=i.scaleY;return e(s)&&t.push("rotate("+s+"deg)"),e(n)&&e(a)&&t.push("scale("+n+","+a+")"),t.length?t.join(" "):"none"}function h(i){return t(i)?i.replace(/^.*//,"").replace(/[?&#].*$/,""):""}function r(i,t){var e;return i.naturalWidth?t(i.naturalWidth,i.naturalHeight):(e=document.createElement("img"),e.onload=function(){t(this.width,this.height)},void(e.src=i.src))}function l(t,e){this.$element=i(t),this.options=i.extend({},l.DEFAULTS,i.isPlainObject(e)&&e),this.isImg=!1,this.isBuilt=!1,this.isShown=!1,this.isViewed=!1,this.isFulled=!1,this.isPlayed=!1,this.playing=!1,this.fading=!1,this.transitioning=!1,this.action=!1,this.target=!1,this.index=0,this.length=0,this.init()}var d=i(window),c=i(document),u="viewer",m=document.createElement(u),v="viewer-toggle",f="viewer-fixed",g="viewer-open",w="viewer-show",p="viewer-hide",b="viewer-fade",y="viewer-in",x="viewer-move",$="viewer-active",C="viewer-invisible",z="viewer-transition",I="viewer-fullscreen",F="viewer-fullscreen-exit",k="viewer-close",Y="img",P="mousedown touchstart pointerdown MSPointerDown",S="mousemove touchmove pointermove MSPointerMove",X="mouseup touchend touchcancel pointerup pointercancel MSPointerUp MSPointerCancel",T="wheel mousewheel DOMMouseScroll",D="transitionend",E="load."+u,L="keydown."+u,V="click."+u,R="resize."+u,q="build."+u,M="built."+u,W="show."+u,_="shown."+u,j="hide."+u,A="hidden."+u,H="view."+u,B="viewed."+u,U="undefined"!=typeof m.style.transition,N=Math.round,O=Math.sqrt,Z=Math.abs,K=Math.min,Q=Math.max,G=parseFloat,J={};i.extend(J,{init:function(){var t=this.options,e=this.$element,s=e.is(Y),n=s?e:e.find(Y),a=n.length,o=i.proxy(this.ready,this);a&&(i.isFunction(t.build)&&e.one(q,t.build),this.trigger(q).isDefaultPrevented()||(U||(t.transition=!1),this.isImg=s,this.length=a,this.count=0,this.$images=n,this.$body=i("body"),t.inline?(e.one(M,i.proxy(function(){this.view()},this)),n.each(function(){this.complete?o():i(this).one(E,o)})):(n.addClass(v),e.on(V,i.proxy(this.start,this)))))},ready:function(){this.count++,this.count===this.length&&this.build()}}),i.extend(J,{build:function(){var t,e,s,n,a=this.options,o=this.$element;this.isBuilt||(t&&t.length||(t=o.parent()),this.$parent=t,this.$viewer=e=i(l.TEMPLATE),this.$canvas=e.find(".viewer-canvas"),this.$footer=e.find(".viewer-footer"),this.$title=e.find(".viewer-title").toggleClass(p,!a.title),this.$toolbar=n=e.find(".viewer-toolbar").toggleClass(p,!a.toolbar),this.$navbar=e.find(".viewer-navbar").toggleClass(p,!a.navbar),this.$button=s=e.find(".viewer-button").toggleClass(p,!a.button),this.$tooltip=e.find(".viewer-tooltip"),this.$player=e.find(".viewer-player"),this.$list=e.find(".viewer-list"),n.find("li[class*=zoom]").toggleClass(C,!a.zoomable),n.find("li[class*=flip]").toggleClass(C,!a.scalable),a.rotatable||n.find("li[class*=rotate]").addClass(C).appendTo(n),a.inline?(s.addClass(I),e.css("z-index",a.zIndexInline),"static"===t.css("position")&&t.css("position","relative")):(s.addClass(k),e.css("z-index",a.zIndex).addClass([f,b,p].join(" "))),o.after(e),a.inline&&(this.render(),this.bind(),this.isShown=!0),this.isBuilt=!0,i.isFunction(a.built)&&o.one(M,a.built),this.trigger(M))},unbuild:function(){var i=this.options,t=this.$element;this.isBuilt&&(i.inline&&!i.container&&t.removeClass(p),this.$viewer.remove())}}),i.extend(J,{bind:function(){this.$viewer.on(V,i.proxy(this.click,this)).on(T,i.proxy(this.wheel,this)),this.$canvas.on(P,i.proxy(this.mousedown,this)),c.on(S,this._mousemove=a(this.mousemove,this)).on(X,this._mouseup=a(this.mouseup,this)).on(L,this._keydown=a(this.keydown,this)),d.on(R,this._resize=a(this.resize,this))},unbind:function(){this.$viewer.off(V,this.click).off(T,this.wheel),this.$canvas.off(P,this.mousedown),c.off(S,this._mousemove).off(X,this._mouseup).off(L,this._keydown),d.off(R,this._resize)}}),i.extend(J,{render:function(){this.initContainer(),this.initViewer(),this.initList(),this.renderViewer()},initContainer:function(){this.container={d.innerWidth(),height:d.innerHeight()}},initViewer:function(){var t,e=this.options,s=this.$parent;e.inline&&(this.parent=t={Q(s.width(),e.minWidth),height:Q(s.height(),e.minHeight)}),(this.isFulled||!t)&&(t=this.container),this.viewer=i.extend({},t)},renderViewer:function(){this.options.inline&&!this.isFulled&&this.$viewer.css(this.viewer)},initList:function(){var e=this.options,s=this.$element,n=this.$list,a=[];this.$images.each(function(s){var n=this.src,o=this.alt||h(n),r=e.url;n&&(t(r)?r=this.getAttribute(r):i.isFunction(r)&&(r=r.call(this,this)),a.push('<li><img src="'+n+'" data-action="view" data-index="'+s+'" data-original-url="'+(r||n)+'" alt="'+o+'"></li>'))}),n.html(a.join("")).find(Y).one(E,{filled:!0},i.proxy(this.loadImage,this)),this.$items=n.children(),e.transition&&s.one(B,function(){n.addClass(z)})},renderList:function(i){var t=i||this.index,e=this.$items.eq(t).width(),s=e+1;this.$list.css({s*this.length,marginLeft:(this.viewer.width-e)/2-s*t})},resetList:function(){this.$list.empty().removeClass(z).css("margin-left",0)},initImage:function(t){var e=this.options,s=this.$image,n=this.viewer,a=this.$footer.height(),o=n.width,h=Q(n.height-a,a),l=this.image||{};r(s[0],i.proxy(function(s,n){var a,r,d=s/n,c=o,u=h;h*d>o?u=o/d:c=h*d,c=K(.9*c,s),u=K(.9*u,n),r={naturalWidth:s,naturalHeight:n,aspectRatio:d,ratio:c/s,c,height:u,left:(o-c)/2,top:(h-u)/2},a=i.extend({},r),e.rotatable&&(r.rotate=l.rotate||0,a.rotate=0),e.scalable&&(r.scaleX=l.scaleX||1,r.scaleY=l.scaleY||1,a.scaleX=1,a.scaleY=1),this.image=r,this.initialImage=a,i.isFunction(t)&&t()},this))},renderImage:function(t){var e=this.image,s=this.$image;s.css({e.width,height:e.height,marginLeft:e.left,marginTop:e.top,transform:o(e)}),i.isFunction(t)&&(this.options.transition?s.one(D,t):t())},resetImage:function(){this.$image.remove(),this.$image=null}}),i.extend(J,{start:function(t){var e=t.target;i(e).hasClass(v)&&(this.target=e,this.show())},click:function(t){var e=i(t.target),s=e.data("action"),n=this.image;switch(s){case"mix":this.isPlayed?this.stop():this.options.inline?this.isFulled?this.exit():this.full():this.hide();break;case"view":this.view(e.data("index"));break;case"zoom-in":this.zoom(.1,!0);break;case"zoom-out":this.zoom(-.1,!0);break;case"one-to-one":1===this.image.ratio?this.zoomTo(this.initialImage.ratio):this.zoomTo(1);break;case"reset":this.reset();break;case"prev":this.prev();break;case"play":this.play();break;case"next":this.next();break;case"rotate-left":this.rotate(-90);break;case"rotate-right":this.rotate(90);break;case"flip-horizontal":this.scale(-n.scaleX||-1,n.scaleY||1);break;case"flip-vertical":this.scale(n.scaleX||1,-n.scaleY||-1);break;default:this.isPlayed&&this.stop()}},load:function(){this.initImage(i.proxy(function(){this.renderImage(i.proxy(function(){this.isViewed=!0,this.trigger(B)},this))},this))},loadImage:function(t){var e=t.target,s=i(e),n=s.parent(),a=n.width(),o=n.height(),h=t.data&&t.data.filled;r(e,i.proxy(function(i,t){var e=i/t,n=a,r=o;o*e>a?h?n=o*e:r=a/e:h?r=a/e:n=o*e,s.css({n,height:r,marginLeft:(a-n)/2,marginTop:(o-r)/2})},this))},resize:function(){this.initContainer(),this.initViewer(),this.renderViewer(),this.renderList(),this.initImage(i.proxy(function(){this.renderImage()},this)),this.isPlayed&&this.$player.find(Y).one(E,i.proxy(this.loadImage,this)).trigger(E)},wheel:function(i){var t=i.originalEvent,e=G(this.options.zoomRatio)||.1,s=1;this.isViewed&&(i.preventDefault(),t.deltaY?s=t.deltaY>0?1:-1:t.wheelDelta?s=-t.wheelDelta/120:t.detail&&(s=t.detail>0?1:-1),this.zoom(-s*e,!0))},keydown:function(i){var t=this.options,e=i.which;if(this.isFulled&&t.keyboard)switch(e){case 27:this.isPlayed?this.stop():t.inline?this.isFulled&&this.exit():this.hide();break;case 37:this.prev();break;case 38:this.zoom(t.zoomRatio,!0);break;case 39:this.next();break;case 40:this.zoom(-t.zoomRatio,!0);break;case 48:case 49:(i.ctrlKey||i.shiftKey)&&(i.preventDefault(),1===this.image.ratio?this.zoomTo(this.initialImage.ratio):this.zoomTo(1))}},mousedown:function(i){var t,e=this.options,s=i.originalEvent,n=s&&s.touches,a=i,o=e.movable?"move":!1;if(this.isViewed){if(n){if(t=n.length,t>1){if(!e.zoomable||2!==t)return;a=n[1],this.startX2=a.pageX,this.startY2=a.pageY,o="zoom"}else this.isSwitchable()&&(o="switch");a=n[0]}o&&(i.preventDefault(),"move"===o&&e.transition&&this.$image.removeClass(z),this.action=o,this.startX=a.pageX||s&&s.pageX,this.startY=a.pageY||s&&s.pageY)}},mousemove:function(i){var t,e=this.options,s=i.originalEvent,n=s&&s.touches,a=i;if(this.isViewed){if(n){if(t=n.length,t>1){if(!e.zoomable||2!==t)return;a=n[1],this.endX2=a.pageX,this.endY2=a.pageY}a=n[0]}this.action&&(i.preventDefault(),this.endX=a.pageX||s&&s.pageX,this.endY=a.pageY||s&&s.pageY,this.change())}},mouseup:function(i){var t=this.action;t&&(i.preventDefault(),"move"===t&&this.options.transition&&this.$image.addClass(z),this.action=!1)}}),i.extend(J,{show:function(){var t,e=this.options;e.inline||this.transitioning||(this.isBuilt||this.build(),i.isFunction(e.show)&&this.$element.one(W,e.show),this.trigger(W).isDefaultPrevented()||(this.$body.addClass(g),t=this.$viewer.removeClass(p),this.$element.one(_,i.proxy(function(){this.view((this.target?this.$images.index(this.target):0)||this.index),this.target=!1},this)),e.transition?(this.transitioning=!0,t.addClass(z).get(0).offsetWidth,t.one(D,i.proxy(this.shown,this)).addClass(y)):(t.addClass(y),this.shown())))},hide:function(){var t=this.options,e=this.$viewer;t.inline||this.transitioning||!this.isShown||(i.isFunction(t.hide)&&this.$element.one(j,t.hide),this.trigger(j).isDefaultPrevented()||(this.isViewed&&t.transition?(this.transitioning=!0,this.$image.one(D,i.proxy(function(){e.one(D,i.proxy(this.hidden,this)).removeClass(y)},this)),this.zoomTo(0,!1,!0)):(e.removeClass(y),this.hidden())))},view:function(t){var e,s,n,a,o,h=this.options,r=this.viewer,l=this.$title;t=Number(t)||0,!this.isShown||this.isPlayed||0>t||t>=this.length||this.isViewed&&t===this.index||this.trigger(H).isDefaultPrevented()||(s=this.$items.eq(t),n=s.find(Y),a=n.data("originalUrl"),o=n.attr("alt"),this.$image=e=i('<img src="'+a+'" alt="'+o+'">'),e.toggleClass(z,h.transition).toggleClass(x,h.movable).css({0,height:0,marginLeft:r.width/2,marginTop:r.height/2}),this.$items.eq(this.index).removeClass($),s.addClass($),this.isViewed=!1,this.index=t,this.image=null,e.one(E,i.proxy(this.load,this)),this.$canvas.html(e),l.empty(),this.renderList(),this.$element.one(B,i.proxy(function(){var i=this.image,t=i.naturalWidth,e=i.naturalHeight;l.html(o+" ("+t+" &times; "+e+")")},this)))},prev:function(){this.view(Q(this.index-1,0))},next:function(){this.view(K(this.index+1,this.length-1))},move:function(i,t){var n=this.image;s(t)&&(t=i),i=G(i),t=G(t),this.isShown&&!this.isPlayed&&this.options.movable&&(n.left+=e(i)?i:0,n.top+=e(t)?t:0,this.renderImage())},zoom:function(i,t){var s,n,a=this.options,o=Q(.01,a.minZoomRatio),h=K(100,a.maxZoomRatio),r=this.image;i=G(i),e(i)&&this.isShown&&!this.isPlayed&&a.zoomable&&(i=0>i?1/(1-i):1+i,s=r.width*i,n=r.height*i,i=s/r.naturalWidth,i=K(Q(i,o),h),i>.95&&1.05>i&&(i=1,s=r.naturalWidth,n=r.naturalHeight),r.left-=(s-r.width)/2,r.top-=(n-r.height)/2,r.width=s,r.height=n,r.ratio=i,this.renderImage(),t&&this.tooltip())},zoomTo:function(i,t,s){var n,a,o=this.image;i=Q(i,0),e(i)&&this.isShown&&!this.isPlayed&&(s||this.options.zoomable)&&(n=o.naturalWidth*i,a=o.naturalHeight*i,o.left-=(n-o.width)/2,o.top-=(a-o.height)/2,o.width=n,o.height=a,o.ratio=i,this.renderImage(),t&&this.tooltip())},rotate:function(i){var t=this.image;i=G(i),e(i)&&this.isShown&&!this.isPlayed&&this.options.rotatable&&(t.rotate=(t.rotate||0)+i,this.renderImage())},rotateTo:function(i){var t=this.image;i=G(i),e(i)&&this.isShown&&!this.isPlayed&&this.options.rotatable&&(t.rotate=i,this.renderImage())},scale:function(i,t){var n=this.image;s(t)&&(t=i),i=G(i),t=G(t),this.isShown&&!this.isPlayed&&this.options.scalable&&(n.scaleX=e(i)?i:1,n.scaleY=e(t)?t:1,this.renderImage())},scaleX:function(i){this.scale(i,this.image.scaleY)},scaleY:function(i){this.scale(this.image.scaleX,i)},play:function(){var t,s=this.options,n=this.$player,a=i.proxy(this.loadImage,this),o=[],h=0,r=0;this.isShown&&!this.isPlayed&&(s.fullscreen&&this.fullscreen(),this.isPlayed=!0,n.addClass(w),this.$items.each(function(t){var e=i(this),l=e.find(Y),d=i('<img src="'+l.data("originalUrl")+'" alt="'+l.attr("alt")+'">');h++,d.addClass(b).toggleClass(z,s.transition),e.hasClass($)&&(d.addClass(y),r=t),o.push(d),d.one(E,{filled:!1},a),n.append(d)}),e(s.interval)&&s.interval>0&&(t=i.proxy(function(){this.playing=setTimeout(function(){o[r].removeClass(y),r++,r=h>r?r:0,o[r].addClass(y),t()},s.interval)},this),h>1&&t()))},stop:function(){this.isPlayed&&(this.isPlayed=!1,clearTimeout(this.playing),this.$player.removeClass(w).empty())},full:function(){var t=this.options,e=this.$image,s=this.$list;this.isShown&&!this.isPlayed&&!this.isFulled&&t.inline&&(this.isFulled=!0,this.$body.addClass(g),this.$button.addClass(F),t.transition&&(e.removeClass(z),s.removeClass(z)),this.$viewer.addClass(f).removeAttr("style").css("z-index",t.zIndex),this.initContainer(),this.viewer=i.extend({},this.container),this.renderList(),this.initImage(i.proxy(function(){this.renderImage(function(){t.transition&&setTimeout(function(){e.addClass(z),s.addClass(z)},0)})},this)))},exit:function(){var t=this.options,e=this.$image,s=this.$list;this.isFulled&&(this.isFulled=!1,this.$body.removeClass(g),this.$button.removeClass(F),t.transition&&(e.removeClass(z),s.removeClass(z)),this.$viewer.removeClass(f).css("z-index",t.zIndexInline),this.viewer=i.extend({},this.parent),this.renderViewer(),this.renderList(),this.initImage(i.proxy(function(){this.renderImage(function(){t.transition&&setTimeout(function(){e.addClass(z),s.addClass(z)},0)})},this)))},tooltip:function(){var t=this.options,e=this.$tooltip,s=this.image,n=[w,b,z].join(" ");this.isShown&&!this.isPlayed&&t.tooltip&&(e.text(N(100*s.ratio)+"%"),this.fading?clearTimeout(this.fading):t.transition?(e.addClass(n).get(0).offsetWidth,e.addClass(y)):e.addClass(w),this.fading=setTimeout(i.proxy(function(){t.transition?e.one(D,function(){e.removeClass(n)}).removeClass(y):e.removeClass(w),this.fading=!1},this),1e3))},toggle:function(){1===this.image.ratio?this.zoomTo(this.initialImage.ratio):this.zoomTo(1)},reset:function(){this.isShown&&!this.isPlayed&&(this.image=i.extend({},this.initialImage),this.renderImage())},destroy:function(){var i=this.$element;this.options.inline?this.unbind():(this.isShown&&this.unbind(),this.$images.removeClass(v),i.off(V,this.start)),this.unbuild(),i.removeData(u)}}),i.extend(J,{trigger:function(t,e){var s=i.Event(t,e);return this.$element.trigger(s),s},shown:function(){var t=this.options;this.transitioning=!1,this.isFulled=!0,this.isShown=!0,this.isVisible=!0,this.render(),this.bind(),i.isFunction(t.shown)&&this.$element.one(_,t.shown),this.trigger(_)},hidden:function(){var t=this.options;this.transitioning=!1,this.isViewed=!1,this.isFulled=!1,this.isShown=!1,this.isVisible=!1,this.unbind(),this.$body.removeClass(g),this.$viewer.addClass(p),this.resetList(),this.resetImage(),i.isFunction(t.hidden)&&this.$element.one(A,t.hidden),this.trigger(A)},fullscreen:function(){var i=document.documentElement;!this.isFulled||document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement||(i.requestFullscreen?i.requestFullscreen():i.msRequestFullscreen?i.msRequestFullscreen():i.mozRequestFullScreen?i.mozRequestFullScreen():i.webkitRequestFullscreen&&i.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT))},change:function(){var i=this.endX-this.startX,t=this.endY-this.startY;switch(this.action){case"move":this.move(i,t);break;case"zoom":this.zoom(function(i,t,e,s){var n=O(i*i+t*t),a=O(e*e+s*s);return(a-n)/n}(Z(this.startX-this.startX2),Z(this.startY-this.startY2),Z(this.endX-this.endX2),Z(this.endY-this.endY2))),this.startX2=this.endX2,this.startY2=this.endY2;break;case"switch":this.action="switched",i>1?this.prev():-1>i&&this.next()}this.startX=this.endX,this.startY=this.endY},isSwitchable:function(){var i=this.image,t=this.viewer;return i.left>=0&&i.top>=0&&i.width<=t.width&&i.height<=t.height}}),i.extend(l.prototype,J),l.DEFAULTS={inline:!1,button:!0,navbar:!0,title:!0,toolbar:!0,tooltip:!0,movable:!0,zoomable:!0,rotatable:!0,scalable:!0,transition:!0,fullscreen:!0,keyboard:!0,interval:5e3,minWidth:200,minHeight:100,zoomRatio:.1,minZoomRatio:.01,maxZoomRatio:100,zIndex:2015,zIndexInline:0,url:"src",build:null,built:null,show:null,shown:null,hide:null,hidden:null},l.TEMPLATE='<div class="viewer-container"><div class="viewer-canvas"></div><div class="viewer-footer"><div class="viewer-title"></div><ul class="viewer-toolbar"><li class="viewer-zoom-in" data-action="zoom-in"></li><li class="viewer-zoom-out" data-action="zoom-out"></li><li class="viewer-one-to-one" data-action="one-to-one"></li><li class="viewer-reset" data-action="reset"></li><li class="viewer-prev" data-action="prev"></li><li class="viewer-play" data-action="play"></li><li class="viewer-next" data-action="next"></li><li class="viewer-rotate-left" data-action="rotate-left"></li><li class="viewer-rotate-right" data-action="rotate-right"></li><li class="viewer-flip-horizontal" data-action="flip-horizontal"></li><li class="viewer-flip-vertical" data-action="flip-vertical"></li></ul><div class="viewer-navbar"><ul class="viewer-list"></ul></div></div><div class="viewer-tooltip"></div><div class="viewer-button" data-action="mix"></div><div class="viewer-player"></div></div>',l.other=i.fn.viewer,i.fn.viewer=function(e){var a,o=n(arguments,1);return this.each(function(){var s,n=i(this),h=n.data(u);if(!h){if(/destroy|hide|exit|stop|reset/.test(e))return;n.data(u,h=new l(this,e))}t(e)&&i.isFunction(s=h[e])&&(a=s.apply(h,o))}),s(a)?this:a},i.fn.viewer.Constructor=l,i.fn.viewer.setDefaults=l.setDefaults,i.fn.viewer.noConflict=function(){return i.fn.viewer=l.other,this}});
    View Code

    样式文件:

    viewer.min.css

    /*!
     * Viewer v0.1.0
     * https://github.com/fengyuanchen/viewer
     *
     * Copyright (c) 2015 Fengyuan Chen
     * Released under the MIT license
     *
     * Date: 2015-09-02T09:08:17.223Z
     */.viewer-container,.viewer-navbar{background-color:#000;overflow:hidden}.viewer-canvas,.viewer-container,.viewer-footer,.viewer-player{right:0;bottom:0;left:0}.viewer-button,.viewer-canvas,.viewer-container,.viewer-footer,.viewer-list,.viewer-navbar,.viewer-open,.viewer-title,.viewer-toolbar,.viewer-toolbar>li{overflow:hidden}.viewer-close:before,.viewer-flip-horizontal:before,.viewer-flip-vertical:before,.viewer-fullscreen-exit:before,.viewer-fullscreen:before,.viewer-next:before,.viewer-one-to-one:before,.viewer-play:before,.viewer-prev:before,.viewer-reset:before,.viewer-rotate-left:before,.viewer-rotate-right:before,.viewer-zoom-in:before,.viewer-zoom-out:before{display:block;20px;height:20px;font-size:0;line-height:0;color:transparent;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARgAAAAUCAYAAABWOyJDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAAQPSURBVHic7Zs/iFxVFMa/0U2UaJGksUgnIVhYxVhpjDbZCBmLdAYECxsRFBTUamcXUiSNncgKQbSxsxH8gzAP3FU2jY0kKKJNiiiIghFlccnP4p3nPCdv3p9778vsLOcHB2bfveeb7955c3jvvNkBIMdxnD64a94GHMfZu3iBcRynN7zAOI7TG15gHCeeNUkr8zaxG2lbYDYsdgMbktBsP03jdQwljSXdtBhLOmtjowC9Mg9L+knSlcD8TNKpSA9lBpK2JF2VdDSR5n5J64m0qli399hNFMUlpshQii5jbXTbHGviB0nLNeNDSd9VO4A2UdB2fp+x0eCnaXxWXGA2X0au/3HgN9P4LFCjIANOJdrLr0zzZ+BEpNYDwKbpnQMeAw4m8HjQtM6Z9qa917zPQwFr3M5KgA6J5rTJCdFZJj9/lyvGhsDvwFNVuV2MhhjrK6b9bFiE+j1r87eBl4HDwCF7/U/k+ofAX5b/EXBv5JoLMuILzf3Ap6Z3EzgdqHMCuF7hcQf4HDgeoHnccncqdK/TvSDWffFXI/exICY/xZyqc6XLWF1UFZna4gJ7q8BsRvgd2/xXpo6P+D9dfT7PpECtA3cnWPM0GXGFZh/wgWltA+cDNC7X+AP4GzjZQe+k5dRxuYPeiuXU7e1qwLpDz7dFjXKRaSwuMLvAlG8zZlG+YmiK1HoFqT7wP2z+4Q45TfEGcMt01xLoNZEBTwRqD4BLpnMLeC1A41UmVxsXgXeBayV/Wx20rpTyrpnWRft7p6O/FdqzGrDukPNtkaMoMo3FBdBSQMOnYBCReyf05s126fU9ytfX98+mY54Kxnp7S9K3kj6U9KYdG0h6UdLbkh7poFXMfUnSOyVvL0h6VtIXHbS6nOP+s/Zm9mvyXW1uuC9ohZ72E9uDmXWLJOB1GxsH+DxPftsB8B6wlGDN02TAkxG6+4D3TWsbeC5CS8CDFce+AW500LhhOW2020TRjK3b21HEmgti9m0RonxbdMZeVzV+/4tF3cBpP7E9mKHNL5q8h5g0eYsCMQz0epq8gQrwMXAgcs0FGXGFRcB9wCemF9PkbYqM/Bas7fxLwNeJPdTdpo4itQti8lPMqTpXuozVRVXPpbHI3KkNTB1NfkL81j2mvhDp91HgV9MKuRIqrykj3WPq4rHyL+axj8/qGPmTqi6F9YDlHOvJU6oYcTsh/TYSzWmTE6JT19CtLTJt32D6CmHe0eQn1O8z5AXgT4sx4Vcu0/EQecMydB8z0hUWkTd2t4CrwNEePqMBcAR4mrBbwyXLPWJa8zrXmmLEhNBmfpkuY2102xxrih+pb+ieAb6vGhuA97UcJ5KR8gZ77K+99xxeYBzH6Q3/Z0fHcXrDC4zjOL3hBcZxnN74F+zlvXFWXF9PAAAAAElFTkSuQmCC);background-repeat:no-repeat}.viewer-zoom-in:before{content:"Zoom In";background-position:0 0}.viewer-zoom-out:before{content:"Zoom Out";background-position:-20px 0}.viewer-one-to-one:before{content:"One to One";background-position:-40px 0}.viewer-reset:before{content:"Reset";background-position:-60px 0}.viewer-prev:before{content:"Previous";background-position:-5pc 0}.viewer-play:before{content:"Play";background-position:-75pt 0}.viewer-next:before{content:"Next";background-position:-90pt 0}.viewer-rotate-left:before{content:"Rotate Left";background-position:-140px 0}.viewer-rotate-right:before{content:"Rotate Right";background-position:-10pc 0}.viewer-flip-horizontal:before{content:"Flip Horizontal";background-position:-180px 0}.viewer-flip-vertical:before{content:"Flip Vertical";background-position:-200px 0}.viewer-fullscreen:before{content:"Enter Full Screen";background-position:-220px 0}.viewer-fullscreen-exit:before{content:"Exit Full Screen";background-position:-15pc 0}.viewer-close:before{content:"Close";background-position:-260px 0}.viewer-container{position:absolute;top:0;font-size:0;line-height:0;-ms-touch-action:none;touch-action:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-color:rgba(0,0,0,.5);direction:ltr!important;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none}.viewer-container ::-moz-selection,.viewer-container::-moz-selection{background-color:transparent}.viewer-container ::selection,.viewer-container::selection{background-color:transparent}.viewer-container img{display:block;100%;min-0!important;max-none!important;height:100%;min-height:0!important;max-height:none!important}.viewer-player,.viewer-tooltip{display:none;position:absolute}.viewer-canvas{position:absolute;top:0}.viewer-footer{position:absolute;text-align:center}.viewer-navbar{background-color:rgba(0,0,0,.5)}.viewer-list{height:50px;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;padding:1px 0;margin:0}.viewer-list>li{float:left;30px;height:50px;overflow:hidden;font-size:0;line-height:0;color:transparent;cursor:pointer;filter:alpha(opacity=50);opacity:.5}.viewer-list>li+li{margin-left:1px}.viewer-list>.viewer-active{filter:alpha(opacity=100);opacity:1}.viewer-player{top:0;cursor:none;background-color:#000}.viewer-player>img{position:absolute;top:0;left:0}.viewer-toolbar{280px;padding:3px 0;margin:0 auto 5px}.viewer-toolbar>li{float:left;24px;height:24px;cursor:pointer;background-color:#000;background-color:rgba(0,0,0,.5);border-radius:50%}.viewer-toolbar>li:hover{background-color:#000;background-color:rgba(0,0,0,.8)}.viewer-toolbar>li:before{margin:2px}.viewer-toolbar>li+li{margin-left:1px}.viewer-toolbar>.viewer-play{30px;height:30px;margin-top:-3px;margin-bottom:-3px}.viewer-toolbar>.viewer-play:before{margin:5px}.viewer-tooltip{top:50%;left:50%;50px;height:20px;margin-top:-10px;margin-left:-25px;font-size:9pt;line-height:20px;color:#fff;text-align:center;background-color:#000;background-color:rgba(0,0,0,.8);border-radius:10px}.viewer-title{display:inline-block;max-90%;margin:0 5% 5px;font-size:9pt;line-height:1;color:#ccc;text-overflow:ellipsis;white-space:nowrap;filter:alpha(opacity=80);opacity:.8}.viewer-title:hover{filter:alpha(opacity=100);opacity:1}.viewer-button{position:absolute;top:-40px;right:-40px;5pc;height:5pc;cursor:pointer;background-color:#000;background-color:rgba(0,0,0,.5);border-radius:50%}.viewer-button:before{position:absolute;bottom:15px;left:15px}.viewer-fixed{position:fixed}.viewer-show{display:block}.viewer-hide{display:none}.viewer-invisible{visibility:hidden}.viewer-toggle{cursor:pointer;cursor:-webkit-zoom-in;cursor:zoom-in}.viewer-move{cursor:move;cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.viewer-fade{filter:alpha(opacity=0);opacity:0}.viewer-in{filter:alpha(opacity=100);opacity:1}.viewer-transition{-webkit-transition:all .3s ease-out;-o-transition:all .3s ease-out;transition:all .3s ease-out}
    View Code

    附上下载栗子:https://files-cdn.cnblogs.com/files/maoye520/tupiandianjifangfa.rar

    其他样式可以自己写~~~~~~~~~~~~~~~~~

    写得不好,可以参考参考~~~~这个东西有个坑就是图片方法全屏的时候浏览器也会跟全屏,需要按 esc  退出才能回到原来页面,哈哈哈~~~~希望有人可以解决,评论反馈给我。

  • 相关阅读:
    ios开发之--使用AFN上传3.1.0上传视频,不走成功回调原因及解决方法
    ios开发之--[_NSInlineData objectForKeyedSubscript:]
    swift开发之--代理协议的使用
    ios开发之--NSString的操作
    ios开发之--条用第三方地图路线导航
    ios开发之--多个按钮单选效果
    ios开发之--首页 导航栏隐藏 下一级页面显示,pop回来显示白条
    ios开发之--令UITableView滚动到指定位置
    Selenium 异常处理
    Selenium 选项卡管理
  • 原文地址:https://www.cnblogs.com/maoye520/p/11133409.html
Copyright © 2020-2023  润新知