-1

这是我面临问题的代码。

让我简单地解释一下这个问题。html 代码包含许多幻灯片,因此当按下箭头键和鼠标滚动时,幻灯片会前后移动。

问题是第一次按下箭头键时,其中的下一个功能不起作用。

但是当我使用滚动时,下一个功能开始执行,然后当我单击左箭头时它可以工作。

但它不是第一次工作。什么问题。?我该如何解决?

这是下一个功能:

next: function() {
            if (!this._slides[this.current-1].buildNext()) {
              this.current = Math.min(this.current + 1, this._slides.length);
              this._update();
            }

这是调用它的代码:

handleWheel: function(e) {
            var delta = 0;
            if (e.wheelDelta) {
              delta = e.wheelDelta/120;
              if (isOpera) {
                delta = -delta;
              }
            } else if (e.detail) {
              delta = -e.detail/3;
            }

            if (delta > 0 ) {
              this.prev();
              return;
            }
            if (delta < 0 ) {
              this.next();
              return;
            }
          },
          handleKeys: function(e) {
            if (/^(input|textarea)$/i.test(e.target.nodeName) ||
                e.target.isContentEditable) {
              return;
            }
            switch (e.keyCode) {
              //case 37: // left arrow
                //this.prev(); break;
              case 39: // right arrow
              case 32: // space
                this.next(); break;
              case 50: // 2
                this.showNotes(); break;
              case 51: // 3
                this.switch3D(); break;
            }
          }
4

1 回答 1

2

这是如果条件是问题的代码

   next: function() {
                if (!this._slides[this.current-1].buildNext()) {
                  this.current = Math.min(this.current + 1, this._slides.length);
                  this._update();
                }
}

这是编辑后的代码,效果很好

next: function() {

              this.current = Math.min(this.current + 1, this._slides.length);
              this._update();
            }
于 2012-09-26T09:02:45.010 回答