JS simple implementation of animation pop-up layer effect _ javascript skills

Source: Internet
Author: User
This article introduces a javascript pop-up layer special effect. you can click to trigger the js pop-up layer, slide over the trigger js pop-up layer, and bring the animation effect to the js pop-up layer, customizable function callback js pop-up layer. JS simple implementation of the animation pop-up layer effect

Animation pop-up layer

0

1

Content display 111

2

Content display 222

3

Content display 333

Script var zindex = 0; function $ id (id) {return document. getElementById (id);} var Bind = function (object, fun) {var args = Array. prototype. slice. call (arguments ). slice (2); return function () {return fun. apply (object, args) ;}} function addEventHandler (oTarget, sEventType, fnHandler) {if (oTarget. addEventListener) {oTarget. addEventListener (sEventType, fnHandler, false);} else if (oTarget. attachEvent) {oTarget. attachE Vent ('on' + sEventType, fnHandler);} else {oTarget ['on' + sEventType] = fnHandler;} var Shower = function () {this. list = null; this. comment = null; this. moveLeft = 80; this. moveTop = 20; this. height = 150; this. width = 250; this. time = 800; this. init = function (lisObj, comObj) {this. list = lisObj; this. comment = comObj; var _ this = this; this. _ fnMove = Bind (this, this. move); (function () {var obj = _ this; addEventHandler (obj. list, "click", obj. _ FnMove) ;}) () ;}; this. move = function () {var _ this = this; var w = 0; var h = 0; var height = 0; // The high var width = 0 of p is displayed; // The p width var t = 0; var startTime = new Date () is displayed (). getTime (); // The execution start time if (! _ This. comment. style. display | _ this. comment. style. display = "none") {_ this. comment. style. display = "block"; _ this. comment. style. height = 0 + "px"; _ this. comment. style. width = 0 + "px"; _ this. list. style. zIndex = ++ zindex; _ this. list. className = "listShow"; var comment = _ this. comment. innerHTML; _ this. comment. innerHTML = ""; // remove the display content var timer = setInterval (function () {var newTime = new Date (). getTime (); var timestamp = newTime-startTime; _ this. comment. style. left = Math. ceil (w) + "px"; _ this. comment. style. top = Math. ceil (h) + "px"; _ this. comment. style. height = height + "px"; _ this. comment. style. width = width + "px"; t ++; var change = (Math. pow (timestamp/_ this. time-1), 3) + 1); // get the basic change according to the running time w = _ this. moveLeft * change; h = _ this. moveTop * change; height = _ this. height * change; width = _ this. width * change; $ id ("show "). innerHTML = w; if (w> _ this. moveLeft) {clearInterval (timer); _ this. comment. style. left = _ this. moveLeft + "px"; _ this. comment. style. top = _ this. moveTop + "px"; _ this. comment. style. height = _ this. height + "px"; _ this. comment. style. width = _ this. width + "px"; _ this. comment. innerHTML = comment; // Reply to display content }}, 1, _ this. comment);} else {_ this. hidden () ;}} this. hidden = function () {var _ this = this; var flag = 1; var hiddenTimer = setInterval (function () {if (flag = 1) {_ this. comment. style. height = parseInt (_ this. comment. style. height)-10 + "px";} else {_ this. comment. style. width = parseInt (_ this. comment. style. width)-15 + "px"; _ this. comment. style. left = parseInt (_ this. comment. style. left) + 5 + "px";} if (flag = 1 & parseInt (_ this. comment. style. height) <10) {flag =-flag;} if (parseInt (_ this. comment. style. width) <20) {clearInterval (hiddenTimer); _ this. comment. style. left = "0px"; _ this. comment. style. top = "0px"; _ this. comment. style. height = "0px"; _ this. comment. style. width = "0px"; _ this. comment. style. display = "none"; if (_ this. list. style. zIndex = zindex) {zindex --;}; _ this. list. style. zIndex = 0; _ this. list. className = "list" ;}}, 1) }} window. onload = function () {// create each menu object var shower1 = new Shower (); shower1.init ($ id ("list1"), $ id ("comment1 ")); var shower2 = new Shower (); shower2.init ($ id ("list2"), $ id ("comment2"); var shower3 = new Shower (); shower3.init ($ id ("list3"), $ id ("comment3");} script

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.