Home > Web Front-end > JS Tutorial > body text

jQuery plug-in expander implements image flipping effects_jquery

WBOY
Release: 2016-05-16 15:58:12
Original
1129 people have browsed it

Share a pop-up flip effect code based on jQuery image. This is implemented based on jQuery HTML5, which contains six different mouse click picture pop-up effects for download. The rendering is as follows:

Introducing CSS and JS

<link href="css/expander.css" rel="stylesheet">
<link href="css/theme.css" rel="stylesheet">
<script src="js/jquery-latest.min.js" type="text/javascript"></script>
<script src="js/expander.min.js"></script>
Copy after login

expander.min.js code

Copy code The code is as follows:

!function(){function a(){var a=this;this.init=function(){$(document).ready(function(){var b=$("
");a.siv=b,$("div.expander-siv").length||$("body").append(b),$("img[data-expander ]").each(function(){var c=$(this);c.attr("src",c.attr("src") "?" (new Date).getTime()),c.load (function(){var b=$(this).attr("data-expander"),c=$("
");if(c.addClass("expander -container"),b=b.replace(/(['"])?([a-zA-Z0-9_] )(['"])?:/g,'"$2": '),b =b?JSON.parse(b):{},b.animation&&c.addClass(b.animation),b.theme||(b.theme="dark",c.addClass("theme"),c.addClass ("dark"),$("div.expander-siv").addClass("dark"),$("div.expander-siv").addClass("theme")),b.speed||(b .speed="normal"),b.url){var d=$(this).clone();d.attr("src",b.url "?" (new Date).getTime()),c .append(d)}else c.append($(this).clone());c.data("options",b),c.data("original",{parent:$(this),position: $(this).offset()}),c.css({position:"absolute",width:$(this).outerWidth(),height:$(this).outerHeight(),top:$(this) .offset().top,left:$(this).offset().left}),$(this).data("container",c),c.addClass("anim-" b.speed),$ ("body").append(c),$(this).on("click",function(){a.pop($(this).data("container"))}),c.on(" click",function(){a.unpop($(this))})}),$(this).bind("expand",function(){a.pop($(this).data("container" ))}),$(this).bind("retract",function(){a.unpop($(this).data("container"))})}),setInterval(function(){a.reLayout ()},2e3)}),$(window).resize(function(){a.reLayout()})},this.reLayout=function(){$("div[data-expanderContainer]").each (function(){if($(this).hasClass("open"))$(this).css({top:$(window).scrollTop() "px",left:"0px",width:" 100%",height:"100%"});else{var b=$(this).data("original");$(this).css({width:b.parent.outerWidth(),height: b.parent.outerHeight(),top:b.parent.offset().top,left:b.parent.offset().left})}})}, this.pop=function(b){a.siv .removeClass(),a.siv.addClass("expander-siv").addClass("theme").addClass(b.data("options").theme),a.siv.addClass("show"), b.addClass("open"),b.css({position:"absolute",top:$(window).scrollTop() "px",left:"0px",width:"100%",height:" 100%"})},this.unpop=function(b){a.siv.removeClass("show");var c=b.data("original").parent;b.css({position:"absolute ",top:c.offset().top "px",left:c.offset().left "px",width:c.outerWidth() "px",height:c.outerHeight() "px"} ),b.removeClass("open")},this.init()}var a=new a}();

JS code:

<script>
    var index = 0;
    var timeout = setInterval(function () {
      if (index > 10) {
        window.clearInterval(timeout)
      }
      $("article").eq(index).addClass("show");
      index++
    }, 300);

    function showFoo() {
      $("#fooId").trigger("expand");
    }

    $("#expandSettings").on("click", function () {
      if ($("ul.settings").hasClass("open")) {
        $("ul.settings").removeClass("open");
      } else {
        $("ul.settings").addClass("open");

      }
    });
</script>

Copy after login

HTML

<section class="main">
<article>
<div class="imgContainer">
<h5>效果一</h5>
<img src="images/chinaz.jpg" data-expander='{animation:"default"}'>
</div>
<div class="imgContainer">
<h5>效果二</h5>
<img src="images/chinaz.jpg" data-expander='{animation:"diamond"}'>
</div>
<div class="imgContainer">
<h5>效果三</h5>
<img src="images/chinaz.jpg" data-expander='{animation:"turn3d"}'>
</div>
<div class="imgContainer">
<h5>效果四</h5>
<img src="images/chinaz.jpg" data-expander='{animation:"flip3d"}'>
</div>
<div class="imgContainer">
<h5>效果五</h5>
<img src="images/chinaz.jpg" data-expander='{animation:"rotate"}'>
</div>
<div class="imgContainer">
<h5>效果六</h5>
<img src="images/chinaz.jpg" data-expander='{animation:"fade"}'>
</div>
</article>
</section>
Copy after login

The above is the entire content of this article, I hope you all like it.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!