多图点击放大并左右滑动

css部分:

    <style type="text/css">
        body {  color: #666; font-family: Helvetica, Arial, sans-serif;  margin: 0;    width:100%;max-width:600px;min-width:300px;background:#ccc;}
        #quanzi-all-main {margin:10px 10px 10px 200px;padding:15px 10px;overflow:hidden;background:#fff;}
        .quanzi-one {height:auto;overflow:hidden;}
        .clear {height:1px;border-top:1px #ccc dashed;margin:1rem 0;}
        .gallery { text-align: center;}
        .quanzi-title {margin:0 0 0.5rem 0;line-height:1.4rem;font-size:0.9rem; }
        .gallery:after { content: ‘‘; display: block; height: 2px; margin: .5em 0 1.4em;}
        .gallery a { display: inline-block;  overflow: hidden;float:left;text-align:center;}
        .baguetteBoxOne {width:100%; margin:10px auto;}

        /* 放大图片之后的样式 */
        #baguetteBox-overlay{display:none;opacity:0;position:fixed;overflow:hidden;top:0;left:0;width:100%;height:100%;z-index:1000000;background-color:#222;background-color:rgba(0,0,0,.8);-webkit-transition:opacity .5s ease;transition:opacity .5s ease}
        #baguetteBox-overlay.visible{opacity:1}
        #baguetteBox-overlay .full-image{display:inline-block;position:relative;width:100%;height:100%;text-align:center}
        #baguetteBox-overlay .full-image figure{display:inline;margin:0;height:100%}
        #baguetteBox-overlay .full-image img{display:inline-block;width:auto;height:auto;max-height:100%;max-width:100%; vertical-align:middle; }
        #baguetteBox-overlay .full-image figcaption{display:block;position:absolute;bottom:0;width:100%;text-align:center;line-height:1.8;color:#ccc;background-color:#000;background-color:rgba(0,0,0,.6);font-family:sans-serif}
        #baguetteBox-overlay .full-image:before{content:"";display:inline-block;height:50%;width:1px;margin-right:-1px}
        #baguetteBox-slider{position:absolute;left:0;top:0;height:100%;width:100%;white-space:nowrap;-webkit-transition:left .4s ease,-webkit-transform .4s ease;transition:left .4s ease,-moz-transform .4s ease;transition:left .4s ease,transform .4s ease}
        #baguetteBox-slider.bounce-from-right{-webkit-animation:bounceFromRight .4s ease-out;animation:bounceFromRight .4s ease-out}
        #baguetteBox-slider.bounce-from-left{-webkit-animation:bounceFromLeft .4s ease-out;animation:bounceFromLeft .4s ease-out}
        .baguetteBox-button#next-button,.baguetteBox-button#previous-button{top:50%;top:calc(50% - 30px);width:44px;height:60px}
        .baguetteBox-button{position:absolute;cursor:pointer;outline:0;padding:0;margin:0;border:0;-moz-border-radius:15%;border-radius:15%;background-color:#323232;background-color:rgba(50,50,50,.5);color:#ddd;font:1.6em sans-serif;-webkit-transition:background-color .4s ease;transition:background-color .4s ease}
        .baguetteBox-button:hover{background-color:rgba(50,50,50,.9)}
        .baguetteBox-button#next-button{right:2%}
        .baguetteBox-button#previous-button{left:2%}
        .baguetteBox-button#close-button{top:20px;right:2%;right:calc(2% + 6px);width:30px;height:30px}
        .baguetteBox-button svg{position:absolute;left:0;top:0}
        .spinner{width:40px;height:40px;display:inline-block;position:absolute;top:50%;left:50%;margin-top:-20px;margin-left:-20px}
        .double-bounce1,.double-bounce2{width:100%;height:100%;-moz-border-radius:50%;border-radius:50%;background-color:#fff;opacity:.6;position:absolute;top:0;left:0;-webkit-animation:bounce 2s infinite ease-in-out;animation:bounce 2s infinite ease-in-out}
        .double-bounce2{-webkit-animation-delay:-1s;animation-delay:-1s}
        @-webkit-keyframes bounceFromRight{0%{margin-left:0}50%{margin-left:-30px}100%{margin-left:0}}
        @keyframes bounceFromRight{0%{margin-left:0}50%{margin-left:-30px}100%{margin-left:0}}
        @-webkit-keyframes bounceFromLeft{0%{margin-left:0}50%{margin-left:30px}100%{margin-left:0}}
        @keyframes bounceFromLeft{0%{margin-left:0}50%{margin-left:30px}100%{margin-left:0}}
        @-webkit-keyframes bounce{0%,100%{-webkit-transform:scale(0);transform:scale(0)}
            50%{-webkit-transform:scale(1);transform:scale(1)}}
        @keyframes bounce{0%,100%{-webkit-transform:scale(0);-moz-transform:scale(0);transform:scale(0)}
            50%{-webkit-transform:scale(1);-moz-transform:scale(1);transform:scale(1)}}

    </style>

html部分:

<div id="quanzi-all-main">

    <!-- 代码 开始 -->
    <div class="quanzi-one">
        <div class="quanzi-title">分离焦虑必须经由分离才能解决,但如何对待孩子因为分离产生的情绪十分重要。我们以往对待分离情绪的态度,往往会走向两个极端。</div>
        <div class="baguetteBoxOne gallery">
            <a href="../../../../img/9.jpg" ><img src="../../../../img/9.jpg"></a>
        </div>
    </div>
    <div class="clear"></div>
    <!-- 代码 结束 -->

    <!-- 代码 开始 -->
    <div class="quanzi-one">
        <div class="quanzi-title">分离焦虑必须经由分离才能解决</div>
        <div class="baguetteBoxOne gallery">
            <a href="../../../../img/1.jpg" data-caption="1"><img src="../../../../img/1.jpg"></a>
            <a href="../../../../img/2.jpg" data-caption="2"><img src="../../../../img/2.jpg"></a>
            <a href="../../../../img/3.jpg" data-caption="3"><img src="../../../../img/3.jpg"></a>
            <a href="../../../../img/4.jpg" data-caption="4"><img src="../../../../img/4.jpg"></a>
        </div>
    </div>
    <div class="clear"></div>
    <!-- 代码 结束 -->

</div>

js部分:(此处需要引入jquery.js)

<script>
    var baguetteBox = function() {
        function t(t, n) {
            L.transforms = f(),
                    L.svg = p(),
                    e(),
                    D = document.querySelectorAll(t),
                    [].forEach.call(D,
                            function(t) {
                                var e = t.getElementsByTagName("a");
                                e = [].filter.call(e,
                                        function(t) {
                                            return j.test(t.href)
                                        });
                                var o = S.length;
                                S.push(e),
                                        S[o].options = n,
                                        [].forEach.call(S[o],
                                                function(t, e) {
                                                    h(t, "click",
                                                            function(t) {
                                                                t.preventDefault ? t.preventDefault() : t.returnValue = !1,
                                                                        i(o),
                                                                        a(e)
                                                            })
                                                })
                            })
        }
        function e() {
            return (b = v("baguetteBox-overlay")) ? (k = v("baguetteBox-slider"), void(w = v("previous-button"), C = v("next-button"), T = v("close-button"))) : (b = y("div"), b.id = "baguetteBox-overlay", document.getElementsByTagName("body")[0].appendChild(b), k = y("div"), k.id = "baguetteBox-slider", b.appendChild(k), w = y("button"), w.id = "previous-button", w.innerHTML = L.svg ? E: "&lt;", b.appendChild(w), C = y("button"), C.id = "next-button", C.innerHTML = L.svg ? x: "&gt;", b.appendChild(C), T = y("button"), T.id = "close-button", T.innerHTML = L.svg ? B: "X", b.appendChild(T), w.className = C.className = T.className = "baguetteBox-button", void n())
        }

        ////*

        ////*

        function n() {
            //      h(b, "click",
            //      function(t) {
            //          t.target && "IMG" !== t.target.nodeName && "FIGCAPTION" !== t.target.nodeName && s()
            //      }),
            h(w, "click",
                    function(t) {
                        t.stopPropagation ? t.stopPropagation() : t.cancelBubble = !0,
                                c()
                    }),
                    h(C, "click",
                            function(t) {
                                t.stopPropagation ? t.stopPropagation() : t.cancelBubble = !0,
                                        u()
                            }),
                    h(T, "click",
                            function(t) {
                                t.stopPropagation ? t.stopPropagation() : t.cancelBubble = !0,
                                        s()
                            }),
                    h(b, "touchstart",
                            function(t) {
                                N = t.changedTouches[0].pageX
                            }),
                    h(b, "touchmove",
                            function(t) {
                                H || (t.preventDefault ? t.preventDefault() : t.returnValue = !1, touch = t.touches[0] || t.changedTouches[0], touch.pageX - N > 40 ? (H = !0, c()) : touch.pageX - N < -40 && (H = !0, u()))
                            }),
                    h(b, "touchend",
                            function() {
                                H = !1
                            }),
                    h(document, "keydown",
                            function(t) {
                                switch (t.keyCode) {
                                    case 37:
                                        c();
                                        break;
                                    case 39:
                                        u();
                                        break;
                                    case 27:
                                        s()
                                }
                            })
        }
        function i(t) {
            if (A !== t) {
                for (A = t, o(S[t].options); k.firstChild;) k.removeChild(k.firstChild);
                X.length = 0;
                for (var e, n = 0; n < S[t].length; n++) e = y("div"),
                        e.className = "full-image",
                        e.id = "baguette-img-" + n,
                        X.push(e),
                        k.appendChild(X[n])
            }
        }

        function o(t) {
            t || (t = {});
            for (var e in P) I[e] = P[e],
            "undefined" != typeof t[e] && (I[e] = t[e]);
            k.style.transition = k.style.webkitTransition = "fadeIn" === I.animation ? "all .4s ease": "slideIn" === I.animation ? "": "all .3s ease",
            "auto" === I.buttons && ("ontouchstart" in window || 1 === S[A].length) && (I.buttons = !1),
                    w.style.display = C.style.display = I.buttons ? "": "none"
        }
        function a(t) {
            "block" !== b.style.display && (M = t, r(M,
                    function() {
                        g(M),
                                m(M)
                    }), d(), b.style.display = "block", setTimeout(function() {
                        b.className = "visible"
                    },
                    50))
        }
        function s() {
            "none" !== b.style.display && (b.className = "", setTimeout(function() {
                        b.style.display = "none"
                    },
                    500))
        }
        function r(t, e) {
            var n = X[t];
            if ("undefined" != typeof n) {
                if (n.getElementsByTagName("img")[0]) return void(e && e());
                imageElement = S[A][t],
                        imageCaption = imageElement.getAttribute("data-caption") || imageElement.title,
                        imageSrc = l(imageElement);
                var i = y("figure"),
                        o = y("img"),
                        a = y("figcaption");
                n.appendChild(i),
                        i.innerHTML = ‘<div class="spinner"><div class="double-bounce1"></div><div class="double-bounce2"></div></div>‘,
                        o.onload = function() {
                            var n = document.querySelector("#baguette-img-" + t + " .spinner");
                            i.removeChild(n),
                            !I.async && e && e()
                        },
                        o.setAttribute("src", imageSrc),
                        i.appendChild(o),
                I.captions && imageCaption && (a.innerHTML = imageCaption, i.appendChild(a)),
                I.async && e && e()
            }
        }
        function l(t) {
            var e = imageElement.href;
            if (t.dataset) {
                var n = [];
                for (var i in t.dataset)"at-" !== i.substring(0, 3) || isNaN(i.substring(3)) || (n[i.replace("at-", "")] = t.dataset[i]);
                keys = Object.keys(n).sort(function(t, e) {
                    return parseInt(t) < parseInt(e) ? -1 : 1
                });
                for (var o = window.innerWidth * window.devicePixelRatio,
                             a = 0; a < keys.length - 1 && keys[a] < o;) a++;
                e = n[keys[a]] || e
            }
            return e
        }
        function u() {
            M <= X.length - 2 ? (M++, d(), g(M)) : I.animation && (k.className = "bounce-from-right", setTimeout(function() {
                        k.className = ""
                    },
                    400))
        }
        function c() {
            M >= 1 ? (M--, d(), m(M)) : I.animation && (k.className = "bounce-from-left", setTimeout(function() {
                        k.className = ""
                    },
                    400))
        }
        function d() {
            var t = 100 * -M + "%";
            "slideIn" === I.animation ? (k.style.opacity = 0, setTimeout(function() {
                        L.transforms ? k.style.transform = k.style.webkitTransform = "translate3d(" + t + ",0,0)": k.style.left = t,
                                k.style.opacity = 1
                    },
                    400)) : L.transforms ? k.style.transform = k.style.webkitTransform = "translate3d(" + t + ",0,0)": k.style.left = t
        }
        function f() {
            var t = y("div");
            return "undefined" != typeof t.style.perspective || "undefined" != typeof t.style.webkitPerspective
        }
        function p() {
            var t = y("div");
            return t.innerHTML = "<svg/>",
            "http://www.w3.org/2000/svg" == (t.firstChild && t.firstChild.namespaceURI)
        }
        function g(t) {
            t - M >= I.preload || r(t + 1,
                    function() {
                        g(t + 1)
                    })
        }
        function m(t) {
            M - t >= I.preload || r(t - 1,
                    function() {
                        m(t - 1)
                    })
        }
        function h(t, e, n) {
            t.addEventListener ? t.addEventListener(e, n, !1) : t.attachEvent("on" + e, n)
        }
        function v(t) {
            return document.getElementById(t)
        }
        function y(t) {
            return document.createElement(t)
        }
        var b, k, w, C, T, N, E = ‘<svg width="44" height="60"><polyline points="30 10 10 30 30 50" stroke="rgba(255,255,255,0.5)" stroke-width="4"stroke-linecap="butt" fill="none" stroke-linejoin="round"/></svg>‘,
                x = ‘<svg width="44" height="60"><polyline points="14 10 34 30 14 50" stroke="rgba(255,255,255,0.5)" stroke-width="4"stroke-linecap="butt" fill="none" stroke-linejoin="round"/></svg>‘,
                B = ‘<svg width="30" height="30"><g stroke="rgb(160, 160, 160)" stroke-width="4"><line x1="5" y1="5" x2="25" y2="25"/><line x1="5" y1="25" x2="25" y2="5"/></g></svg>‘,
                I = {},
                P = {
                    captions: !0,
                    buttons: "auto",
                    async: !1,
                    preload: 2,
                    animation: "slideIn"
                },
                L = {},
                M = 0,
                A = -1,
                H = !1,
                j = /.+\.(gif|jpe?g|png|webp)/i,
                D = [],
                S = [],
                X = [];
        return [].forEach || (Array.prototype.forEach = function(t, e) {
            for (var n = 0; n < this.length; n++) t.call(e, this[n], n, this)
        }),
        [].filter || (Array.prototype.filter = function(t, e, n, i, o) {
            for (n = this, i = [], o = 0; o < n.length; o++) t.call(e, n[o], o, n) && i.push(n[o]);
            return i
        }),
        {
            run: t
        }
    } ();
</script>
<script>
    // 先判断baguetteBoxOne 的数量,并给每一个baguetteBoxOne 加上相应的ID值 然后给出旗下a标签不同的样式属性。
    $(document).ready(function(){

        var ln=$(".baguetteBoxOne").size();
        var obj = $(‘.baguetteBoxOne‘);

        obj.each(function(i){ $(this).attr(‘id‘,"quanzi-pic_"+i); })

        for (var i=0; i < ln; i++){

            var j=$("#quanzi-pic_"+i).find("a").size();
            if(j==1) {
                $("#quanzi-pic_"+i).find("a").css({"width":"80%","max-height":"220px"});
                $("#quanzi-pic_"+i).find("a").find("img").css({"width":"100%"});
            }
            else if(j==2 || j==4) {
                $("#quanzi-pic_"+i).find("a").css({"width":"48%","height":"100px","margin":"0 2% 0.6rem 0"});
                $("#quanzi-pic_"+i).find("a").find("img").css({"min-width":"100%","min-height":"120px","max-width":"200%"});
            }
            else if(j>4 || j==3) {
                $("#quanzi-pic_"+i).find("a").css({"width":"32%","height":"60px","margin": "0 1.3% 0.6rem 0"});
                $("#quanzi-pic_"+i).find("a").find("img").css({"min-width":"100%","min-height":"60px","max-width":"200%"});
            }
        }
    });
</script>
<script> <!-- 这段JS 要放在最后面 -->
baguetteBox.run(‘.baguetteBoxOne‘, {
    animation: ‘fadeIn‘,
});
</script>
时间: 2024-10-11 05:39:37

多图点击放大并左右滑动的相关文章

SmoothImageDemo图片点击放大特效

SmoothImageDemo图片点击放大特效 图片点击有缩放动画效果,从图片本身的位置放大,缩小到图片的位置,不会截动态图... 下载地址:http://www.devstore.cn/code/info/646.html 运行截图:  

Android浏览图片,点击放大至全屏效果

最近做一个项目类似于QQ空间,做到照片浏览的功能,对于QQ空间中点击图片放大至全屏,感觉效果很赞,于是也做了个类似的效果.如下. 我不知道QQ那个是怎么做的,我的思路如下: 首先,从图片缩略界面跳转到图片详情页面,应该是从一个Activity跳转到另外一个Activity,应该图片详情页面也有很多操作,用View或者Dialog不是很好.所以现在难点就是,如何使得前一个界面的ImageView在另外一个界面做缩放切割动画. 一般缩略界面的ImageView的是如上图所示的正方形的,并且是CENT

WebView显示h5图片并点击放大过多后的内存泄漏问题

最近在项目开发中用webview去显示加载h5内容,而h5内容中有一些图片,并且可以点击放大看图.在比较变态的测试方法(点击图片放大,关闭当前界面,再进入,再点击图片放大,大概10次左右)后,会导致图片点击没反映了(其实就是webview内存泄漏了).错误信息如下: 12-02 10:46:19.824: E/Surface(19632): dequeueBuffer failed (Invalid argument) 12-02 10:46:19.824: E/ViewRootImpl(196

如何使用手机CAD看图将图纸放大缩小?

如何使用手机CAD看图将图纸放大缩小?对于CAD行业的小伙伴们来说,CAD图纸使他们最经常见到的图纸,而且都是dwg格式的,那要怎么进行查看了,在电脑中我们都是知道可以使用CAD看图软件来量CAD图纸进行放大缩小的.那在移动端也可以吗?那这个答案是肯定可以的,那么如何使用手机CAD看图将图纸放大缩小呢?大家知道要怎么来进行操作吗?那下面小编就来教教大家具体操作方法,想要了解的朋友也可以一起来看看,希望能够帮助到你们. 使用步骤一:打开您手机上面的CAD看图软件,如果您手机上面没有CAD看图软件,

图片点击放大插件

最近因为需要找了个图片点击放大的插件,感觉还行吧~~ 底下给香瓜文件下载参考↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 如图: 接下来放香瓜代码: 主要用到下面的样式文件和js文件<link rel="stylesheet" href="css/viewer.min.css" /> <script type="text/javascript" src="js/viewer.min.js"

仿美团外卖,饿了吗 两个ListView联动,左边点击切换右边,右边滑动切换左边

先上效果图: 实现思路: 1.先说右边标题: 首先,右边的数据源集合中的Javabean中含有三个属性name,type,title,而每个条目中会默认含有一个标题. 如果这是第一个条目,就让标题显示出来,再如果这个条目的类型和上一个条目的类型不一样,就让这个条目的标题显示出来,否则,就隐藏标题,  这样我们就做到了每种类型只有第一个数据标题显示出来 接着,在Listview的外层(也就是MainActivity的布局文件中),默认放一个标题(下面都称作是主标题) 最后,设置右边Listview

图片点击放大

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1d9421 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px "PingFang SC"; color: #1d9421 } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px } p.

动画--android图片点击放大动画,并遮挡旁边的控件

http://blog.csdn.net/s13488941815/article/details/40649823: 首先是点击放大可以使用android自带的缩放动画,因为要遮盖其他控件,就需要控件处在最上层,这里需要调用bringTofront方法@Overridepublic boolean onTouch(View v, MotionEvent event) {// TODO Auto-generated method stubswitch (event.getAction()) {c

iOS 图片点击放大, 再次点击缩小

XWScanImage  是一个自定义的类, 评论留Q 发 ImageView = [[UIImageView alloc]init]; ImageView.backgroundColor = SetColor(160, 160, 160); //为UIImageView1添加点击事件 UITapGestureRecognizer *tapGestureRecognizer1 = [[UITapGestureRecognizer alloc] initWithTarget:self action