-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 に答える