【问题标题】:ion Range Slider : How to determine which handle has changedion Range Slider:如何确定哪个句柄已更改
【发布时间】:2015-04-30 00:42:34
【问题描述】:

您好,我正在使用 IonRangeSlider(版本 2.0.6)并且想知道哪个手柄被拖入其他手柄以对该信息执行音频搜索。 目前这段代码没有帮助。

          $('#scrubber').ionRangeSlider( {
                min: 0,
                max: 50,
                from: 10,
                to: 20,
                type: 'double',

                keyboard: false,

                onChange: function ( e ) {


                    var start = e.from,
                        end = e.to;

                            /*Bug here*/
                    audio.currentTime = start;  

                    audio.currentTime = end;







                }

            } );

onChange 方法没有帮助,因为它不提供有关当前是否正在拖动左(开始)或右(结束)句柄的信息。 只要价值发生变化,它就会启动 我想要的是一些类似的东西。

     /* start */
onLeftHandleChange:function(start){

audio.currentTime = start;
}

/* end */

onRightHandleChange: function(end){ 

audio.currentTime = end
}


/*----------------------------------------------------------------*/

                            OR

/*--------------------------------------------------------------*/



if(start value changes){
audio.currentTime = start
}

if(end value changes) {
audio.currentTime  = end
}

我已阅读文档,但似乎找不到任何方法。

dom 元素分别更新滑块 (.irs-from) 和 (.irs-to),而不必一次更新所有滑块,从而给了我希望

任何帮助或不同的插件将不胜感激。我已经使用过 dxRangeSlider,它也有同样的问题

【问题讨论】:

    标签: jquery rangeslider


    【解决方案1】:

    诀窍是下载 livequery 插件 (https://plugins.jquery.com/livequery/),它会在元素出现在 dom 中时检测它们 并使用 css 类 (.irs-from) 和 (.irs-to) 监听以下两个 span 元素的更改。这些类由 ion Slider 插件插入。为此目的不需要 Onchange 事件。

             $( '.irs-from' ).livequery( function () {
    
                    $( '.irs-from' ).bind( 'DOMSubtreeModified', function () {
    
                        /* when left handle  is being dragged */
    
                        console.log( 'LEFT VALUE ' + $( this ).html() );
                    } );
                } );
    
    
    
                $( '.irs-to' ).livequery( function () {
    
                    $( '.irs-to' ).bind( 'DOMSubtreeModified', function () {
    
                    /* when right handle is dragged */
    
                        console.log( 'RIGHT VALUE' + $( this ).html() );
                    } );
                } );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多