We have previously released the flex version of the link jumper effect, now based on the new version of HTML5 jumper effect is also implemented, the nuances of which we have improved, such as link tilt when the offset direction is always vertical and so on. Look at the effect first.
The implementation of the algorithm and flex basically consistent, in this does not do further analysis, the algorithm used in the matrix operation, so in this paste the matrix operation of the package.
var matrix=function (options) {if (!) ( This instanceof Arguments.callee) {return new Arguments.callee (options); } this.init (options);}; matrix.prototype={init:function (options) {This.matrix=options.matrix; }, Add:function (MTX) {var Omtx=this.matrix; var newmtx=[]; if (!mtx.length| |! mtx[0].length| | mtx.length!=omtx.length| | Mtx[0].length!=omtx[0].length) {return; } for (Var i=0,len1=omtx.length;i<len1;i++) {var rowmtx=omtx[i]; Newmtx.push ([]); for (Var j=0,len2=rowmtx.length;j<len2;j++) {Newmtx[i][j]=rowmtx[j]+mtx[i][j]; }} this.matrix=newmtx; return this; }, Multiply:function (MTX) {var omtx = Mtx.matrix; var mtx = This.matrix; var newmtx=[]; if (!isnan (MTX)) {for (Var i=0,len1=omtx.length;i<len1;i++) {var rowmtx=omtx[i] ; Newmtx.push ([]); for (Var j=0,len2=rowmtx.length;j<len2;j++) {omtx[i][j]*=mtx; }} return new Matrix ({matrix:newmtx}); } var sum=0; for (Var i=0,len1=omtx.length;i<len1;i++) {var rowmtx=omtx[i]; Newmtx.push ([]); for (Var m=0,len3=mtx[0].length;m<len3;m++) {for (Var j=0,len2=rowmtx.length;j<len2;j++) { SUM+=OMTX[I][J]*MTX[J][M]; } newmtx[newmtx.length-1].push (sum); sum=0; }} this.matrix=newmtx; return this; } }; This. Matrix=matrix;
Only the addition and multiplication are encapsulated, and the other arithmetic methods can transform the matrix expression, such as translation, rotation, and so on. If you need source code, you can apply for email. [Email protected]
HTML5 implementing the link jumper effect