jQuery UI Sliders - Select overlapping sliders based on dragging direction

前端 未结 7 1590
猫巷女王i
猫巷女王i 2021-01-02 11:27

I have this simple jQuery UI Slider setup with a range and a two default values that overlap. The entire thing (with a few bells and whistles) can be found in this jsfiddle:

7条回答
  •  半阙折子戏
    2021-01-02 12:10

    Put this into the initialising area, where the variables are declared:

    this._originalVal;
    

    Put this into the _mouseCapture function right before the call to _slide:

    this._originalVal = this.values();
    

    And this into the _mouseDrag function, also right before the call to _slide

    if (this._originalVal[0] === this._originalVal[1]
          && normValue > this._originalVal[0]) {
        this._handleIndex = 1;
    } else if (this._originalVal[0] === this._originalVal[1]
                 && normValue < this._originalVal[0]) {
        this._handleIndex = 0;
    }
    

    I just added an else if to the above code; it's working fine in jQuery 1.8.14 for both left and right button handlers.

提交回复
热议问题