Example of multi-block effect of image cutting with JavaScript implementation

Source: Internet
Author: User
Tags extend setinterval

This article mainly introduces the JavaScript implementation of the image cutting multiple effects, involving JavaScript operation pictures and CSS style skills, the need for friends can refer to the

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 5, 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 11 9 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148-149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179-18 0 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209-210 211 212 213 214 215 216 217 218 <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < HTML xmlns= "http://www.w3.org/1999/xhtml" xml:lang= "ru" > <head> <title></title> <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/> <style type=" text/css "> line{display:none; z-index:1; left:0; top:0;} #l ine1{display:block; container{position:relative; width:564px; height:294px; overflow:hidden; border{border:5px Olid #000; corner{Position:absolute; width:282px height:147px; background: #ccc; overflow:hidden; lefttop,.inlefttop{ Position:absolute; left:0; top:0; Right:auto; Bottom:auto; }. righttop,.inrighttop{Position:absolute; right:0 top:0; left:auto; bottom:auto; rightbottom,.inrightbottom{ Position:absolute; right:0; bottom:0; Top:auto; Left:auto; }. leftbottom,.inleftbottom{Position:absolute; left:0 bottom:0; top:auto; right:auto;} </style> </head> & Ltbody> <script src= "jquery-1.6.2.min.js" type= "Text/javascript" ></script> <script type= "text/" JavaScript > Function Crossline (container,option,callback) {var linex=$ ("<div style=" width:2000px;height:4px ; Overflow:hidden;position:absolute;background: #FACC41; left:0;top:0;z-index:1 ' ></div> '); var liney=$ ("<div style= ' width:4px;height:2000px;overflow:hidden;position:absolute;background: #FACC41; left:0; Top:0;z-index:1 ' ></div> '); var _option={"display": "None", "Targetposx": Container.width ()/2-2, "Targetposy": Container.height ()/2-2, "Time": 500 , "Freq": 10}; $.extend (_option,option); Option=_option; var targetposx=option.targetposx; var Targetposy=option.targetposy; var time=option.time; var freq=option.freq; Times=time/freq; Container.append (LineX). Append (Liney); Start campaign var lxt=linex.position (). Top; var lyl=liney.position (). Left; Xpertime=targetposx/times; Ypertime=targetposy/times; var count=0; var si=setinterval (function () {count++; if (Count>=tim)ES) {clearinterval (SI); if (typeof (callback) = = "function") {callback ();} if (option.display== "None") {Linex.remove (); Liney.remove (); } if (Lxt+ypertime<=targetposy) {LXT + = Ypertime; Linex.css ("Top", LXT); else{lxt=targetposy linex.css ("Top", Targetposy);} if (lyl+xpertime<=targetposx) {lyl = Xpertime; LineY.css ("Left ", lyl);} else{lyl=targetposx; Liney.css ("left", Targetposx);}},freq); function Picsplit (line1,line2,container,option) {//begin line1.css ("Z-index", 2);/* var targetx=282; var targety=147; * * var _option={"Targetx": Container.width ()/2, "Targety": Container.height ()/2, "time": +, "Freq": 10}; $.extend (_option,option); Option=_option; var targetx=option.targetx; var targety=option.targety; var containerwidth=container.width (); var containerheight=container.height (); * * Copy four, put in four containers, placed in four corners, and then move///div0-4 container, placed in the four corners of Var div0=$ ("<div></div>"). css ({"position": "Absolute", " Left ': 0, Top: 0, ' right ': "Auto", "bottom": "Auto", "width": targetx, "height": targety, "Z-indeX ":" 2 "," Overflow ":" Hidden "}). Appendto (container); var div1=$ ("<div></div>"). css ({"position": "Absolute", "left": Targetx, "top": 0, "right": "Auto", "bottom" : "Auto", "width": containerwidth-targetx, "height": targety, "Z-index": "2", "Overflow": "Hidden"}). Appendto (Container ); var div2=$ ("<div></div>"). css ({"position": "Absolute", "left": Targetx, "top": targety, "right": "Auto", " Bottom ":" Auto "," width ": targetx," height ": containerheight-targety," Z-index ":" 2 "," Overflow ":" Hidden "}). Appendto ( container); var div3=$ ("<div></div>"). css ({"position": "Absolute", "left": 0, "top": targety, "right": "Auto", "bottom" : "Auto", "width": targetx, "height": containerheight-targety, "Z-index": "2", "Overflow": "Hidden"}). Appendto ( container); templ0-4 copied layer var templ0=line1.clone (). css ({"position": "Absolute", "left": 0, "top": 0, "right": "Auto", "Bottom": " Auto "," Z-index ":" 2 "}). Appendto (DIV0); var templ1=line1.clone (). css ({"position": "Absolute", "left":-targetx, "top": 0, "right": "Auto", "bottom": "Auto", " Z-index ":"2 "}). Appendto (DIV1); var templ2=line1.clone (). css ({"position": "Absolute", "left":-targetx, "top":-targety, "right": "Auto", "Bottom": " Auto "," Z-index ":" 2 "}). Appendto (DIV2); var templ3=line1.clone (). css ({"position": "Absolute", "left": 0, "top":-targety, "right": "Auto", "bottom": "Auto", " Z-index ":" 2 "}). Appendto (DIV3); LINE1.CSS ("Display", "none"); LINE2.CSS ("Display", "block"); Start campaign var time=option.time; var freq=option.freq; var times=time/freq; var count=0; var xleftpertime=3; var xrightpertime=3; var ytoppertime=3; var ybottompertime=3; var l0=div0.position (). Left; var t0=div0.position (). Top; var l1=div1.position (). Left; var t1=div1.position (). Top; var l2=div2.position (). Left; var t2=div2.position (). Top; var l3=div3.position (). Left; var t3=div3.position (). Top; var si=setinterval (function () {count++; if (count>=times) {clearinterval (SI); Div0.remove (); Div1.remove (); Div2.remove (); Div3.remove (); } l0=l0-xleftpertime; T0=t0-ytoppertime; L1=l1+xrightpertime; T1=t1-ytoppertime; L2=l2+xrightpertime; T2=t2+ybottompertime; L3=l3-xleftpertime; T3=t3+ybottompertime; Div0.css ("Left", (l0-xleftpertime) + "px"); Div0.css ("Top", (t0-ytoppertime) + "px"); Div1.css ("Left", (l1+xrightpertime) + "px"); Div1.css ("Top", (t1-ytoppertime) + "px"); Div2.css ("Left", (l2+xrightpertime) + "px"); Div2.css ("Top", (t2+ybottompertime) + "px"); Div3.css ("Left", (l3-xleftpertime) + "px"); Div3.css ("Top", (t3+ybottompertime) + "px"); },FREQ); } </script> <div class= "container" id= "container" > <div class= "line" id= "line1" ><img src= " 1820432103.jpg "alt=" "/></div> <div class=" line "id=" line2 "><img src=" 1110183294.jpg "alt=" "/> </div> </div> <input type= "button" value= "Go" onclick= "Javascript:go ()"/> <script type= "text/ JavaScript "> var line1=$ (" #line1 "); var line2=$ ("#line2"); LINE1.CSS ("Display", "block"); var container=$ ("#container"); function Go () {var option={"display": "None"}; Crossline (container,option,gopicsplit);} var container=$ ("#container") ; Function GOPIcsplit () {picsplit (Line1,line2,container);} </script> </body> </html>

The

wants this article to help you with your JavaScript programming.

Related Article

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.