| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- function Animate() {
- this.$animatCover = document.getElementById('animatCover');
- this.$flashDot = this.$animatCover.children;
- this.t;
- this.flag = false;
- }
- Animate.prototype = {
- init: function () {
- console.log(this.$flashDot)
- var _this = this;
- for (var i = 0; i < _this.$flashDot.length; i++) {
- (function (num) {
- _this.$flashDot[num].addEventListener('click', function (e) {
- _this.paneltaggle(num);
- e.stopPropagation();
- })
- }(i))
- }
- },
- flash: function () {
- var num = 0;
- var maxlength = 5100;
- var _this = this;
- this.t = setInterval(function () {
- num += 100;
- if (num > maxlength) {
- num = 0;
- }
- for (var i = 0; i < _this.$flashDot.length; i++) {
- _this.$flashDot[i].style.backgroundPositionY = num + 'px';
- }
- }, 30)
- },
- showAll:function(){
- var _this = this;
- for (var i = 0; i < _this.$flashDot.length; i++) {
- (function (num) {
- _this.cancelFlash();
- var currobj = _this.$flashDot[num];
- currobj.children[0].style.width = '100px';
- currobj.children[1].classList.add("showPanel");
- }(i))
- }
- },
- paneltaggle: function (currIndex) {
- if (this.flag) {
- this.cancelFlash();
- var currobj = this.$flashDot[currIndex];
- currobj.children[0].style.width = '100px';
- currobj.children[1].classList.add("showPanel");
- } else {
- this.flash();
- this.flag = true;
- for (var i = 0; i < this.$flashDot.length; i++) {
- this.$flashDot[i].children[1].style.opacity = 0;
- this.$flashDot[i].children[1].classList.remove("showPanel");
- this.$flashDot[i].children[0].style.width = '0';
- }
- }
- },
- cancelFlash: function () {
- clearInterval(this.t);
- this.flag = false;
- }
- }
- var animate = new Animate();
|