jquery Shutter effect implementation code (different direction) _jquery

Source: Internet
Author: User

Demo01.htm
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Direction Feedback </title>
<style type= "Text/css" >
html,body{margin:0;padding:50px;}
#wrap {position:relative;width:400px;height:300px;background: #33aa00; margin:50px;display:inline-block;font-size : 50px;text-align:center;line-height:300px;overflow:hidden;}
</style>
<body>
<div id= "Wrap" >
Direction Feedback
</div>
<div id= "Result" >
<span style= "color: #FFF;" > Feedback Direction </span>
</div>
<script src= ". /jquery-1.8.0.min.js "type=" Text/javascript "></script>
<script src= "Rollingmask-0.1.0.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$.rollingmask ({
ObjID: "Wrap",
content:$ ("#result"). HTML ()
});
});
</script>
</body>

Rollingmask-0.1.0.js
Copy Code code as follows:

/**
* Shutter effect in different directions
*
**/
$.extend ({
Rollingmask:function (Opt,callback) {
This.defaults = {
ObjID: "",//Container ID
Content: "Test",//shutter contents
opacity:0.8,
Time of fadespeed:150//shutter disappearing
};
Parameter initialization
var opts = $.extend (this.defaults,opt);

var ContentID = Opts.objid + "_content";
var showid = Opts.objid + "_show";

$ ("#" + Opts.objid). Bind ("MouseEnter mouseleave",
Function (e) {
var w = $ (this). width ();
var h = $ (this). Height ();
var x = (E.pagex-this.offsetleft-(W/2)) * (W > H?) (h/w): 1);
var y = (E.pagey-this.offsettop-(H/2)) * (H > w?) (w/h): 1);
var direction = Math.Round (((Math.atan2 (y, x) * (180/MATH.PI)) + 180)/90) + 3)% 4;
var eventtype = E.type;

if (E.type = = ' MouseEnter ') {
$ ("#" + Opts.objid). Append ("<div id=\" "+ contentid+" \ ">" + opts.content + "</div>");
$ ("#" + ContentID). css ({
"Position": "Absolute",
"width": w + "px",
"Height": H + "px",
"Top": "0px",
"Left": "0px",
"Background": "#F55",
Opacity:opts.opacity
});
switch (direction) {
Case 0:
$ ("#" + ContentID). CSS ("Top",-H + "px");
Break
Case 1:
$ ("#" + ContentID). CSS ("left", W + "px");
Break
Case 2:
$ ("#" + ContentID). CSS ("top", H + "px");
Break
Case 3:
$ ("#" + ContentID). CSS ("left", W + "px");
Break
}
$ ("#" + ContentID). Animate ({"Top": "0px", "left": "0px"});
}else{
$ ("#" + ContentID). fadeout (Opts.fadespeed, function () {
$ ("#" + ContentID). Remove ();
});
}
}
);
}
});

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.