Implementation of shutter animation effect based on JavaScript not only Flas can realize _javascript skill

Source: Internet
Author: User

See this kind of what blinds the animation, thought all is the flash realization, recently suddenly a flash, thought of using JS implementation (although I do not do front-end, I do. net). Although the code implemented, but more chaotic, the first figure:

A JS animation, previously thought that only flash can achieve

The code is mainly mathematical calculation, and then combined with HTML,CSS to create a similar effect of flash.

The main parts of the code are posted below:

function all {for (Var i=;i<self.rows;i++) {for (var j =; J < Self.columns; J + +) {if (!books[i][j)) return F
Alse;
} return true; function Resetbooks {for (var i=;i<self.rows;i++) {for (var j =; J < Self.columns; J + +) {Books[i][j]=fals
E
} return true;
} var self=this,timer=null,_iindex=;
var initdir=[[[,],[,]],[[-,],[,]],[[,-],[-,]],[[,-],[,]],[[,-],[,],[,],[-,]]],dir=initdir[];
var weight=[,,,,]; var initpos=[[{x:,y:-}],[{x:self.columns-,y:-}],[{x:self.columns-,y:self.rows}],[{x:,y:self.rows}],[{x:
self.columns/,y:self.rows/}]]; Timer=setinterval (function () {var n=[]; for (var i=;i<self.predivs.length;i++) {var _div=null,x=, y=; for (Var j=;j <dir.length;j++) {x=self.predivs[i].x+dir[j][]; y=self.predivs[i].y+dir[j][]; if (x>=&&y>=& &x<self.columns&&y<self.rows&&!self.books[y][x]) {self.books[y][x]=true; _div=
SELF.ZZDIVSTATCK[Y][X];
N.push ({x:x,y:y}); _div.style.backgroundimage = "url (" + Self.zzimages[_iiNdex] + ")";
_div.style.backgroundpositionx = (x * self.zzdivw) + "px";
_div.style.backgroundpositiony = (Y * self.zzdivh) + "px";
}} self.predivs=n; if (All (Self.books)) {resetbooks (self.books); var _r=util.randomweight (weight); self.predivs = Initpos[_r]; dir=
Initdir[_r];
_iindex++; } if (_iindex>=+self.zzimages.length) {_iindex=}},);

The above code is the use of JavaScript implementation of the shutter animation effect, I hope to help!

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.