中文字幕免费精品_亚洲视频自拍_亚洲综合国产激情另类一区_色综合咪咪久久

原生javascript+css3編寫的3D魔方動畫旋扭特效
來源:易賢網 閱讀:1410 次 日期:2016-07-20 15:11:56
溫馨提示:易賢網小編為您整理了“原生javascript+css3編寫的3D魔方動畫旋扭特效”,方便廣大網友查閱!

這篇文章主要介紹了原生javascript+css3編寫的3D魔方動畫旋扭特效的相關資料,需要的朋友可以參考下

代碼如下:

<!DOCTYPE html>

<html>

<head>

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 <title></title>

 <meta charset="utf-8" />

 <script language="javascript" type="text/javascript">

  var cache = {};

  (function (exports) {

   function Cube(opts) {

    opts = opts || {};

    this.parent = opts.parent; //插入到哪里

    this.browserPrefix = opts.browserPrefix;

    this.width = opts.width;

    this.height = opts.height;

    this.cubZ = opts.cubZ;

    this.face = opts.face;

    this.row = opts.row;

    this.column = opts.column;

    this.offsetX = this.column * (this.width + opts.marginX); //

    this.offsetY = this.row * (this.height + opts.marginY);//

    this.offsetZ = this.face * (this.cubZ + opts.marginZ);//

    this.positiveZ = this.cubZ / 2;

    this.negativeZ = -this.cubZ / 2;

    this.cubFaceInfo = opts.cubFaceInfo;

    this.dimension = opts.dimension;

    this.centerX = (this.dimension * this.width + (this.dimension - 1) * opts.marginX) / 2;

    this.centerY = (this.dimension * this.height + (this.dimension - 1) * opts.marginY) / 2;

    this.centerZ = (this.dimension * this.cubZ + (this.dimension - 1) * opts.marginZ) / 2;

    this.translateX = this.offsetX - this.centerX; //把中心點設為原點

    this.translateY = this.offsetY - this.centerY; //

    this.translateZ = this.cubZ / 2 + this.offsetZ - this.centerZ; //offsetZ按上面計算應該跟x,y在一個平面上即后面,但實際上由于要形成立方體,在Z軸上已經后退了cubZ/2個距離,故為和上面保持一致在一個面上,這里需要再加回cubZ/2個距離,使默認的xyz原點都在一個平面上即立方體后面左上角三維坐標系,以這個點作為參考點平移和設置旋轉原點

    this.cubeFace = [];

    this.rotateTransfrom = "";

    this.init();

   }

   Cube.prototype = {

    init: function () {

     this.createCubeBox();

     this.createFront();

     this.createBack();

     this.createTop();

     this.createBottom();

     this.createLeft();

     this.createRight();

    },

    createCubeBox: function () {

     this.Box = document.createElement('div');

     this.Box.style.width = this.width + "px";

     this.Box.style.height = this.height + "px";

     this.Box.style.left = "50%";

     this.Box.style.top = "50%";

     this.Box.style.position = "absolute";

     this.Box.style[this.browserPrefix + "TransformStyle"] = "preserve-3d";

     this.Box.style[this.browserPrefix + "Perspective"] = "0";

     //     this.Scene.style[this.browserPrefix + "backfaceVisibility"] = "hidden";

     this.intalTransform = "translateZ(" + this.translateZ + "px) translateX(" + this.translateX + "px) translateY(" + this.translateY + "px)";

     this.Box.style[this.browserPrefix + "Transform"] = this.intalTransform;

     this.Box.style[this.browserPrefix + "TransformOrigin"] = "" + (-this.translateX) + "px " + (-this.translateY) + "px " + (-this.translateZ) + "px";

     this.parent.appendChild(this.Box);

     this.x = window.getComputedStyle(this.Box).getPropertyValue('left');

     this.y = window.getComputedStyle(this.Box).getPropertyValue('top');

     this.matrix3d = window.getComputedStyle(this.Box).getPropertyValue('transform');

    },

    createFace: function () {

     var face = document.createElement('div');

     face.style.margin = 0;

     face.style.position = "absolute";

     face.style.width = this.width + "px";

     face.style.height = this.height + "px";

     return face;

    },

    createFront: function () {

     var face = this.createFace();

     face.style[this.browserPrefix + "Transform"] = "translateZ(" + this.positiveZ + "px) "

     this.cubeFace.push(face);

     this.front = face;

     this.Box.appendChild(face);

    },

    createBack: function () {

     var face = this.createFace();

     face.style[this.browserPrefix + "Transform"] = "translateZ(" + this.negativeZ + "px) ";

     this.cubeFace.push(face);

     this.back = face;

     this.Box.appendChild(face);

    },

    createTop: function () {

     var face = this.createFace();

     face.style[this.browserPrefix + "Transform"] = "rotateX(90deg) translateZ(" + this.positiveZ + "px) ";

     this.cubeFace.push(face);

     this.top = face;

     this.Box.appendChild(face);

    },

    createBottom: function () {

     var face = this.createFace();

     face.style[this.browserPrefix + "Transform"] = "rotateX(90deg) translateZ(" + this.negativeZ + "px) ";

     this.cubeFace.push(face);

     this.bottom = face;

     this.Box.appendChild(face);

    },

    createLeft: function () {

     var face = this.createFace();

     face.style[this.browserPrefix + "Transform"] = "rotateY(90deg) translateZ(" + this.negativeZ + "px) ";

     this.cubeFace.push(face);

     this.left = face;

     this.Box.appendChild(face);

    },

    createRight: function () {

     var face = this.createFace();

     face.style[this.browserPrefix + "Transform"] = "rotateY(90deg) translateZ(" + (this.positiveZ) + "px) ";

     this.cubeFace.push(face);

     this.right = face;

     this.Box.appendChild(face);

    }

   }

   exports.magicCube = function (opts) {

    opts = opts || {};

    this.parent = opts.parent || document.getElementsByTagName('body')[0];

    this.dimension = opts.dimension || 3; //魔方級數

    this.cubWidth = opts.cubWidth || 50; //單個立方體寬度

    this.cubHidth = opts.cubHidth || 50; //單個立方體告訴

    this.marginLeft = opts.marginLeft || 0;

    this.marginTop = opts.marginLeft || 0;

    this.marginZ = opts.marginZ || 0;

    this.cubZ = opts.cubZ || 50; //單個立方體Z軸距離

    this.sceneWidth = opts.sceneWidth; //3d場景寬度

    this.sceneHeight = opts.sceneHeight; //3d場景高度

    this.Perspective = opts.Perspective || 0; //投影值

    this.cubFaceInfo = opts.cubFaceInfo || { front: { backGround: "rgba(0,255,255,.5)" }, back: { backGround: "rgba(153,204,255,.5)" }, left: { backGround: "rgba(128,0,128,.5)" }, right: { backGround: "rgba(255,0,255,.5)" }, top: { backGround: "rgba(255,153,204,.5)" }, bottom: { backGround: "rgba(0,204,255,.5)" }, inner: { backGround: "rgba(100,100,100,.5)" } }; //立方體面信息

    this.angle = opts.angle || 90;

    this.rollbackPoint = opts.rollbackPoint || 10;

    this.faceCount = this.dimension * this.dimension; //每面立方體個數

    this.count = this.dimension * this.dimension * this.dimension; //立方體總個數

    this.cubes = [];

    this.browserPrefix = "";

    this.isRunning = 0;

    this.timer = null;

    this.rotateFace;

    this.moveDirect = true;//正向隨機動作還是回歸,默認為正向

    this.cubeMoveQueue = [];

    this.rollMoveStack = [];//動作回歸的堆棧

    this.init();

   };

   magicCube.prototype = {

    init: function () {

     this.start();

    },

    create3dScene: function () {

     this.Scene = document.createElement('div');

     //this.Scene.className = "cube";

     var width = this.sceneWidth || this.clientWidth,

      height = this.sceneHeight || this.clientHeight;

     this.Scene.style.width = width + "px";

     this.Scene.style.height = height + "px";

     this.Scene.style.position = "relative";

     this.Scene.style[this.browserPrefix + "TransformStyle"] = "preserve-3d";

     this.Scene.style[this.browserPrefix + "Perspective"] = this.Perspective + "px";

     //     this.Scene.style[this.browserPrefix + "backfaceVisibility"] = "hidden";

     this.Scene.style[this.browserPrefix + "Transform"] = "rotateX(-30deg) rotateY(30deg) ";

     this.parent.appendChild(this.Scene);

    },

    create: function (face, row, column) {

     return new Cube({

      parent: this.Scene,

      dimension: this.dimension,

      width: this.cubWidth,

      height: this.cubHidth,

      cubZ: this.cubZ,

      face: face,

      row: row,

      column: column,

      browserPrefix: this.browserPrefix,

      cubFaceInfo: this.cubFaceInfo,

      marginX: this.marginLeft,

      marginY: this.marginTop,

      marginZ: this.marginZ,

      dimension: this.dimension

     });

    },

    createMagicCube: function (index) {

     var face = 0, row = 0, column = 0;

     for (var i = 0; i < this.count; i++) {

      this.cubes.push(this.create(face, row, column));

      this.cubes[this.cubes.length - 1].index = this.cubes.length - 1;

      column++;

      if ((i + 1) % this.dimension === 0) {

       row++;

       column = 0;

      }

      if ((i + 1) % this.faceCount === 0) {

       face++;

       row = 0;

      }

     }

    },

    drawBackGroundColor: function () {

     for (var face in this.cubFaceInfo) {

      if (face == "inner") {

       this.setInnerBKColor(this.cubFaceInfo[face].backGround);

      }

      else {

       var cube = this.getCubesByFace(face);

       for (var i = 0, len = cube.length; i < len; i++) {

        cube[i][face].style.background = this.cubFaceInfo[face].backGround;

       }

      }

     }

    },

    setInnerBKColor: function (color) {

     for (var i = 0; i < this.count; i++) {

      for (var j = 0; j < 6; j++) {

       if (this.cubes[i].cubeFace[j].style.background == "") {

        this.cubes[i].cubeFace[j].style.background = color;

       }

      }

     }

    },

    getZFace: function (zIndex) {

     var zFace = [];

     if (zIndex < 1 || zIndex > this.dimension)

      return null;

     for (var i = (zIndex - 1) * this.faceCount; i < zIndex * this.faceCount; i++) {

      zFace.push(this.cubes[i]);

     }

     return zFace;

    },

    getXFace: function (xIndex) {

     var xFace = [];

     if (xIndex < 1 || xIndex > this.dimension)

      return null;

     for (var i = 0; i < this.count; i++) {

      if (i % this.dimension == 0)

       xFace.push(this.cubes[i + xIndex - 1]);

     }

     return xFace;

    },

    getYFace: function (yIndex) {

     var yFace = [];

     if (yIndex < 1 || yIndex > this.dimension)

      return null;

     for (var i = 0; i < this.count; i++) {

      if (i % this.faceCount == (yIndex - 1) * this.dimension) {

       for (var j = 0; j < this.dimension; j++)

        yFace.push(this.cubes[i + j]);

      }

     }

     return yFace;

    },

    getSideCubes: function (cubes, circleIndex) {

     var sides = [], top = [], left = [], bottom = [], right = [];

     if (circleIndex < 0 || circleIndex > this.dimension / 2 - 1)

      return null;

     for (var i = 0, count = this.dimension - circleIndex * 2; i < count; i++) {

      top.push(cubes[circleIndex * this.dimension + circleIndex + i]);

      left.push(cubes[circleIndex * this.dimension + circleIndex + i * this.dimension]);

      bottom.push(cubes[(this.dimension - 1 - circleIndex) * this.dimension + circleIndex + i]);

      right.push(cubes[circleIndex * this.dimension + circleIndex + i * this.dimension + (this.dimension - (circleIndex * 2) - 1)]);

     }

     sides.push(this.orderByDesc(top));

     sides.push(left);

     sides.push(bottom);

     sides.push(this.orderByDesc(right));

     return sides;

    },

    getCubesByFace: function (face) {

     switch (face) {

      case "front": return this.getZFace(this.dimension);

      case "back": return this.getZFace(1);

      case "left": return this.getXFace(1);

      case "right": return this.getXFace(this.dimension);

      case "top": return this.getYFace(1);

      case "bottom": return this.getYFace(this.dimension);

     }

    },

    moveMagicCube: function () {

     if (this.cubes.length < 1) return;

     //var cubes = this.getYFace(2);

     //for (var i = 0, len = cubes.length; i < len; i++) {

     // cubes[i].Box.className = "rotate";

     //}

     //隨機產生3D轉動方向

     this.isRunning = 0;

     var direct = this.random(1, 3), rotateDirect = "", getFaceFun;

     // direct=3;

     switch (direct) {

      case 1: rotateDirect = "rotateX"; getFaceFun = this.getXFace; break;

      case 2: rotateDirect = "rotateY"; getFaceFun = this.getYFace; break;

      case 3: rotateDirect = "rotateZ"; getFaceFun = this.getZFace; break;

     }

     this.rotateFace = rotateDirect;

     this.cubeRotateStatus = [];

     for (var i = 1; i <= this.dimension; i++) {

      var status = this.random(0, 2);

      this.cubeRotateStatus.push(status);

      switch (status) {

       case 0: break;//不轉動

       case 1: this.rotateBox(this.angle, rotateDirect, i, getFaceFun.call(this, i)); break;//正向轉動90

       case 2: this.rotateBox(-this.angle, rotateDirect, i, getFaceFun.call(this, i)); break;//反向轉動90

      }

     }

     var flag = false;

     for (var i = 0, len = this.cubeRotateStatus.length; i < len; i++) {

      if (this.cubeRotateStatus[i]) {

       flag = true;

       break;

      }

     }

     if (!flag) {//一個都沒轉的情況 則強制補充一個

      var index = this.random(1, this.dimension);

      this.rotateBox(this.angle, rotateDirect, index, getFaceFun.call(this, index)); //正向轉動90

      this.cubeRotateStatus[index - 1] = 1;//全都不轉動 默認選出一個 使其正向轉動指定度數

     }

     setTimeout(this.timerFun, 100);

     this.rollMoveStack.push({ rotateFace: this.rotateFace, cubeRotateStatus: this.cubeRotateStatus });//記錄動作狀態

     if (this.rollMoveStack.length == this.rollbackPoint)//判斷當達到閥值時切換動作方向為回歸

      this.moveDirect = false;

    },

    moveRollBackCube: function () {

     var record = this.rollMoveStack.pop(), getFaceFun;

     this.rotateFace = record.rotateFace;

     this.isRunning = 0;

     switch (record.rotateFace) {

      case "rotateX": getFaceFun = this.getXFace; break;

      case "rotateY": getFaceFun = this.getYFace; break;

      case "rotateZ": getFaceFun = this.getZFace; break;

     }

     this.cubeRotateStatus = [];

     for (var i = 0, len = record.cubeRotateStatus.length; i < len; i++) {

      var dimensionIndex = i+1, status = record.cubeRotateStatus[i];

      if (status == 1) {

       this.cubeRotateStatus.push(2);//1 變2,2變1

       this.rotateBox(-this.angle, record.rotateFace, dimensionIndex, getFaceFun.call(this, dimensionIndex)); //反向轉動90

      }

      else if (status == 2) {

       this.cubeRotateStatus.push(1);//1 變2,2變1

       this.rotateBox(this.angle, record.rotateFace, dimensionIndex, getFaceFun.call(this, dimensionIndex)); //反向轉動90

      }

      else {

       this.cubeRotateStatus.push(0);

      }

     }

     setTimeout(this.timerFun, 100);

     if (this.rollMoveStack.length == 0)//判斷當達到0時切換動作為正向隨機

      this.moveDirect = true;

    },

    intersect: function (source, target) {

     var data = [];

     for (var i = 0, len = source.length; i < len; i++) {

      var index = target.indexOf(source[i]);

      if (index >= 0)

       data.push(source[i])

     }

     return data;

    },

    orderByDesc: function (datas) {

     var temp;

     for (var i = 0; i < datas.length - 1; i++) {

      for (var j = i + 1; j < datas.length; j++) {

       if (parseFloat(datas[i].index) < parseFloat(datas[j].index)) {

        temp = datas[i];

        datas[i] = datas[j];

        datas[j] = temp;

       }

      }

     }

     return datas;

    },

    getSideBackGround: function (sideFaces, face) {

     var backGrounds = [];

     for (var i = 0, len = sideFaces.length; i < len; i++) {

      backGrounds.push(sideFaces[i][face].style.background);

     }

     return backGrounds;

    },

    setRotateDirectSideBackGround: function (faceCubes, sideFace, offset, status) {

     var oldSides = this.getSideCubes(faceCubes, 0), backColor = [];

     var offsetNIndex, offsetPIndex;

     for (var j = 0; j < 4; j++) {

      offsetPIndex = (j - offset + 4) % 4;

      offsetNIndex = (j + offset) % 4;

      if (this.rotateFace == "rotateY") {

       if (status == 1)//正向

       {

        backColor[j] = this.getSideBackGround(oldSides[offsetPIndex], sideFace[offsetPIndex]);

       }

       else//反向

       {

        backColor[j] = this.getSideBackGround(oldSides[offsetNIndex], sideFace[offsetNIndex]);

       }

      }

      else {

       if (status == 2)//正向

       {

        backColor[j] = this.getSideBackGround(oldSides[offsetPIndex], sideFace[offsetPIndex]);

       }

       else//反向

       {

        backColor[j] = this.getSideBackGround(oldSides[offsetNIndex], sideFace[offsetNIndex]);

       }

      }

     }

     for (var j = 0; j < 4; j++) {

      for (var k = 0; k < oldSides[j].length; k++) {

       oldSides[j][k][sideFace[j]].style.background = backColor[j][k];

      }

     }

    },

    setRotateOtherDirectSideBackGround: function (faceCubes, otherFace, offset, status) {

     var oldSides = [], backColor = [];

     var offsetNIndex, offsetPIndex;

     for (var i = 0; i <= parseInt(this.dimension / 2) - 1; i++) {

      oldSides = this.getSideCubes(faceCubes, i), backColor = [];

      for (var j = 0; j < 4; j++) {

       offsetPIndex = (j - offset + 4) % 4;

       offsetNIndex = (j + offset) % 4;

       if (this.rotateFace == "rotateY") {

        if (status == 1)//正向

        {

         backColor[j] = this.getSideBackGround(oldSides[offsetPIndex], otherFace);

        }

        else//反向

        {

         backColor[j] = this.getSideBackGround(oldSides[offsetNIndex], otherFace);

        }

       }

       else {

        if (status == 2)//正向

        {

         backColor[j] = this.getSideBackGround(oldSides[offsetPIndex], otherFace);

        }

        else//反向

        {

         backColor[j] = this.getSideBackGround(oldSides[offsetNIndex], otherFace);

        }

       }

      }

      for (var j = 0; j < 4; j++) {

       for (var k = 0; k < oldSides[j].length; k++) {

        oldSides[j][k][otherFace].style.background = backColor[j][k];

       }

      }

     }

    },

    animationEnd: function () {

     var offset = this.angle / 90, faceCubes = [], otherFace;

     var zSideFace = ["top", "left", "bottom", "right"], xSideFace = ["back", "top", "front", "bottom"], ySideFace = ["back", "left", "front", "right"], sideFace = [];

     for (var i = 0, len = this.cubeRotateStatus.length; i < len; i++) {

      var status = this.cubeRotateStatus[i];

      if (status) {

       var dimensionIndex = i + 1;

       switch (this.rotateFace) {

        case "rotateX": faceCubes = this.getXFace(dimensionIndex); sideFace = xSideFace; if (dimensionIndex == 1) otherFace = "left"; else if (dimensionIndex == this.dimension) otherFace = "right"; break;

        case "rotateY": faceCubes = this.getYFace(dimensionIndex); sideFace = ySideFace; if (dimensionIndex == 1) otherFace = "top"; else if (dimensionIndex == this.dimension) otherFace = "bottom"; break;

        case "rotateZ": faceCubes = this.getZFace(dimensionIndex); sideFace = zSideFace; if (dimensionIndex == 1) otherFace = "back"; else if (dimensionIndex == this.dimension) otherFace = "front"; break;

       }

       this.setRotateDirectSideBackGround(faceCubes, sideFace, offset, status);

       if (dimensionIndex == 1 || dimensionIndex == this.dimension)

        this.setRotateOtherDirectSideBackGround(faceCubes, otherFace, offset, status);

      }

     }

     // console.info(this.rollMoveStack.length + "," + this.moveDirect);

     if (this.moveDirect)

      this.moveMagicCube();

     else

      this.moveRollBackCube();

     // alert("運行結束");

    },

    bindAnimationEvent: function () {

     var loopMove = function () {

      cache.magicCube.isRunning--;//由于按組轉動,顧要等組成員都完成再進行新的動畫

      if (cache.magicCube.isRunning == 0)

       cache.magicCube.animationEnd();

     }

     for (var i = 0; i < this.count; i++) {

      this.prefixedEvent(this.cubes[i].Box, "AnimationEnd", loopMove, true);

     }

     cache.magicCube = this;//緩存,避免內存泄露

    },

    rotateBox: function (angle, rotateDirect, faceIndex, cubes) {

     if (cubes != null) {

      var startStatus = rotateDirect + "(0deg)", endStatus = rotateDirect + "(" + angle + "deg)";

      // this.changeAnimationStatus("mydhua", startStatus, endStatus)

      for (var i = 0, len = cubes.length; i < len; i++) {

       var ruleName = "roateRule" + faceIndex + i;

       this.isRunning++;//組成員轉動統計

       //if (cubes[i].rotateTransfrom != "")

       // startStatus = cubes[i].rotateTransfrom;

       cubes[i].rotateTransfrom = endStatus;

       if (this.findKeyframesRule(ruleName) == null)

        this.createKeyframesRule(ruleName, cubes[i].intalTransform + " " + startStatus, cubes[i].intalTransform + " " + endStatus);

       else

        this.changeAnimationStatus(ruleName, cubes[i].intalTransform + " " + startStatus, cubes[i].intalTransform + " " + endStatus);

       cubes[i].Box.style[this.browserPrefix + "AnimationName"] = "none";

       this.cubeMoveQueue.push({ cube: cubes[i], rule: ruleName });

      }

     }

    },

    findKeyframesRule: function (rule) {

     var ruleName = this.browserPrefix == "" ? "KEYFRAMES_RULE" : this.browserPrefix.toUpperCase() + "_KEYFRAMES_RULE";

     var ss = document.styleSheets;

     for (var i = 0; i < ss.length; ++i) {

      for (var j = 0; j < ss[i].cssRules.length; ++j) {

       if (ss[i].cssRules[j].type == window.CSSRule[ruleName] && ss[i].cssRules[j].name == rule) { return ss[i].cssRules[j]; }

      }

     }

     return null;

    },

    createKeyframesRule: function (rule, startStatus, endStatus) {

     var prefix = this.browserPrefix == "" ? "" : "-" + this.browserPrefix + "-";

     var sheet;

     if (document.styleSheets.length < 1)

      sheet = this.createSheets();

     else

      sheet = document.styleSheets[0];

     var selectorText = "@" + prefix + "keyframes " + rule;

     var cssText = "0% { " + prefix + "transform: " + startStatus + "; } 100% { " + prefix + "transform: " + endStatus + "; }"

     if (sheet.insertRule) {

      sheet.insertRule(selectorText + "{" + cssText + "}", 0);

     } else if (sheet.addRule) {//兼容IE

      sheet.addRule(selectorText, cssText, 0);

     }

    },

    removeKeyframeRule: function (keyframes) {

     var length = keyframes.cssRules.length;

     var keyframeString = [];

     for (var i = 0; i < length; i++) {

      keyframeString.push(keyframes.cssRules[i].keyText);

     }

     //移除動畫幀規則

     for (var i = 0, j = length; i < j; i++) {

      if (this.browserPrefix == "webkit" || this.browserPrefix == "Moz")

       keyframes.deleteRule(keyframeString[i]);

      else

       keyframes.deleteRule(i); //兼容IE

     }

    },

    changeAnimationStatus: function (animationName, startStatus, endStatus) {

     var keyframes = this.findKeyframesRule(animationName);

     this.removeKeyframeRule(keyframes);

     //重新設置幀規則

     var prefix = this.browserPrefix == "" ? "" : "-" + this.browserPrefix + "-";

     keyframes.appendRule("0% { " + prefix + "transform: " + startStatus + "; }");

     keyframes.appendRule("100% { " + prefix + "transform: " + endStatus + "; }");

    },

    createSheets: function () {

     // 創建 <style> 標簽

     var style = document.createElement("style");

     // 可以添加一個媒體(/媒體查詢,media query)屬性

     // style.setAttribute("media", "screen")

     // style.setAttribute("media", "only screen and (max-width : 1024px)")

     // 對WebKit hack :(

     style.appendChild(document.createTextNode(""));

     // 將 <style> 元素加到頁面中

     document.head.appendChild(style);

     return style.sheet;

    },

    prefixedEvent: function (element, type, callback, isAdd) {

     var pfx = ["webkit", "moz", "MS", "o", ""];

     for (var p = 0; p < pfx.length; p++) {

      if (!pfx[p]) type = type.toLowerCase();

      if (isAdd)

       element.addEventListener(pfx[p] + type, callback, false);

      else

       element.removeEventListener(pfx[p] + type, callback, false);

     }

    },

    start: function () {

     this.css();

     this.prefix();

     this.create3dScene();

     this.createMagicCube();

     this.drawBackGroundColor();

     this.bindAnimationEvent();//綁定動畫播放完成事件

     this.moveMagicCube();  //立即開始動畫

     // this.timer = setInterval(this.timerFun, 100);

    },

    timerFun: function () {

     var _this = cache.magicCube;

     if (_this.isRunning >= _this.dimension) {

      for (var i = 0, len = _this.cubeMoveQueue.length; i < len; i++) {

       var animation = _this.cubeMoveQueue.shift();

       animation.cube.Box.style[_this.browserPrefix + "Animation"] = animation.rule + " 2s linear 1"; // Chrome, Safari 和 Opera 代碼

      }

     }

    },

    css: function () {

     var d = document,

      doc = d.documentElement,

      body = d.body;

     this.clientWidth = doc.clientWidth;

     this.clientHeight = doc.clientHeight;

     if (d.compatMode != "CSS1Compat") {

      this.clientWidth = body.clientWidth;

      this.clientHeight = body.clientHeight;

     }

     // console.log(this.width +'////'+ this.height)

    },

    random: function (min, max) {

     return (Math.random() * (max - min + 1) + min) >> 0;

    },

    prefix: function () {

     var N = navigator.appName, ua = navigator.userAgent, tem;

     var M = ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);

     if (M && (tem = ua.match(/version\/([\.\d]+)/i)) != null) M[2] = tem[1];

     M = M ? [M[1], M[2]] : [N, navigator.appVersion, '-?'];

     M = M[0];

     if (M == "Chrome") { this.browserPrefix = "webkit"; }

     if (M == "Firefox") { this.browserPrefix = "Moz"; }

     if (M == "Safari") { this.browserPrefix = "webkit"; }

     if (M == "MSIE") { this.browserPrefix = "ms"; }

    }

   };

  }(window));

 </script>

</head>

<body style="background-color:black">

 <script>

  var cube = new magicCube({ parent: null, dimension: 3, cubWidth: 100, cubHidth: 100, marginLeft: 10, marginTop: 10, marginZ: 10, cubZ: 100 });

 </script>

</body>

</html>

注:在此基礎上可以加上鼠標控制事件,可以直接通過鼠標控制器任意方向的旋扭,也可以稍加改進用于炫酷展示圖片!后續有時間我將加上這些功能,與大家再次分享!

更多信息請查看網絡編程
由于各方面情況的不斷調整與變化,易賢網提供的所有考試信息和咨詢回復僅供參考,敬請考生以權威部門公布的正式信息和咨詢為準!

2026上岸·考公考編培訓報班

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
云南網警備案專用圖標
聯系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網
云南網警報警專用圖標
中文字幕免费精品_亚洲视频自拍_亚洲综合国产激情另类一区_色综合咪咪久久
国产毛片一区二区| 亚洲自拍偷拍福利| 在线视频日韩精品| 久久精品免费| 亚洲福利在线看| 免费观看成人www动漫视频| 韩国av一区二区三区| 久久乐国产精品| 亚洲电影自拍| 欧美日本在线| 亚洲资源av| 国产亚洲激情| 欧美成人高清| 亚洲影院在线观看| 1000部国产精品成人观看| 美女久久一区| 艳女tv在线观看国产一区| 国产精品美女久久久浪潮软件| 久久精品国产一区二区三| 亚洲二区在线观看| 国产精品男人爽免费视频1| 久久成人免费电影| 亚洲伦理网站| 国产主播一区| 欧美视频福利| 久热精品视频在线免费观看| 一区二区三区四区蜜桃| 黄色成人免费观看| 欧美日韩一区二区免费视频| 久久精品国产69国产精品亚洲 | 亚洲女人天堂av| 亚洲毛片一区| 国产亚洲成精品久久| 欧美r片在线| 亚洲影院在线| 一区二区三区日韩在线观看| 在线播放日韩专区| 国产精品一区2区| 欧美体内she精视频| 久色婷婷小香蕉久久| 亚洲欧美日韩国产成人精品影院| 亚洲精选视频免费看| 伊人久久综合| 国产精品日本精品| 欧美日韩激情小视频| 久久亚洲二区| 久久国产免费| 久久aⅴ国产欧美74aaa| 中文久久乱码一区二区| 亚洲国产精品美女| 在线看日韩av| 激情一区二区三区| 国产精品每日更新在线播放网址| 欧美精品v日韩精品v韩国精品v| 久久高清免费观看| 欧美一区二区三区免费观看| 午夜欧美理论片| 亚洲欧美综合v| 亚洲尤物在线| 亚洲视频综合在线| 一本色道久久99精品综合| 亚洲黑丝在线| 亚洲精品字幕| 亚洲激情视频网站| 亚洲第一视频网站| 亚洲精品中文字幕女同| 亚洲国产精品久久久久秋霞不卡| 好吊色欧美一区二区三区视频| 国产日韩欧美夫妻视频在线观看| 欧美性猛交xxxx免费看久久久 | 久久精品91久久久久久再现| 午夜久久电影网| 久久riav二区三区| 欧美超级免费视 在线| 美女视频黄免费的久久| 久久久国际精品| 免费日韩成人| 欧美日韩国语| 国产精品毛片在线| 国内精品久久久久影院薰衣草 | 午夜一区二区三视频在线观看| 亚洲一区亚洲| 欧美制服丝袜第一页| 免费观看不卡av| 欧美精品日韩综合在线| 欧美日韩亚洲一区在线观看| 欧美视频在线免费看| 国产日韩欧美一区二区| 很黄很黄激情成人| 亚洲人成毛片在线播放| 亚洲一区二区精品视频| 久久精品91| 欧美日韩国产色视频| 国产日韩在线一区| 欧美欧美午夜aⅴ在线观看| 国产精品福利av| 国产午夜精品理论片a级大结局| 伊人久久久大香线蕉综合直播| 亚洲美女在线视频| 久久国产高清| 欧美日韩美女| 韩国av一区二区三区四区| 亚洲精品九九| 欧美资源在线| 欧美日本一区| 激情久久一区| 亚洲在线免费| 欧美国产在线电影| 国产麻豆91精品| 亚洲激情国产| 欧美在线观看一区二区三区| 欧美精品一区二区三区四区| 国产一区二区三区久久精品| 日韩午夜剧场| 欧美91福利在线观看| 国产精品久久99| 亚洲人成在线免费观看| 久久精品视频免费观看| 欧美日韩你懂的| 亚洲黄色成人网| 久久亚洲精品视频| 国产日韩欧美在线观看| 在线观看中文字幕亚洲| 亚洲一卡二卡三卡四卡五卡| 欧美激情亚洲自拍| 久热综合在线亚洲精品| 国产精品入口日韩视频大尺度| 亚洲免费福利视频| 欧美成人一二三| 1769国内精品视频在线播放| 欧美一区久久| 国产精品一区二区欧美| 亚洲一区二区在线播放| 欧美日韩一区视频| 99国产精品久久久久久久| 国产精品国产自产拍高清av| 亚洲高清视频一区| 免费成人你懂的| 在线免费一区三区| 久久久久久久久久久一区| 久久中文字幕一区| 国产一区二区三区精品久久久| 亚洲自拍啪啪| 麻豆久久婷婷| 亚洲第一福利社区| 久久久www成人免费精品| 国产午夜亚洲精品羞羞网站| 亚洲欧美清纯在线制服| 国产精品视频xxxx| 亚洲女同精品视频| 国产精品国产a级| 一区二区三区国产| 国产精品免费看久久久香蕉| 亚洲天堂免费在线观看视频| 国产精品成av人在线视午夜片| 一个色综合av| 欧美日韩在线三级| 午夜国产精品视频| 影音先锋中文字幕一区| 欧美国产精品v| 狠狠色狠狠色综合日日tαg| 久久久国产精品一区二区三区| 尤物yw午夜国产精品视频明星| 乱码第一页成人| 在线观看中文字幕亚洲| 欧美粗暴jizz性欧美20| 亚洲免费av网站| 欧美日韩午夜剧场| 香蕉成人久久| 在线观看欧美日韩国产| 欧美精品 日韩| 国产亚洲精品自拍| 免费成人av资源网| 在线视频亚洲欧美| 狠狠色丁香婷婷综合影院| 欧美精品一区三区在线观看| 亚洲综合视频一区| 亚洲国产高潮在线观看| 国产精品久久久久久妇女6080| 久久国产精品99精品国产| 日韩网站在线看片你懂的| 国产欧美日韩中文字幕在线| 欧美成人免费在线观看| 午夜精品久久| 一区二区亚洲精品| 国产精品一区二区三区久久久| 免费亚洲视频| 性高湖久久久久久久久| a4yy欧美一区二区三区| 国产在线视频欧美一区二区三区| 亚洲自拍偷拍福利| 日韩一级大片在线| 红桃视频亚洲| 国产精自产拍久久久久久蜜 | 亚洲免费在线视频| 91久久精品日日躁夜夜躁国产| 国产日韩成人精品| 国产精品ⅴa在线观看h| 欧美成人精品高清在线播放| 久久精品亚洲一区二区|