简体   繁体   English

无法拖动滑块手柄

[英]Can not drag slider handles

I've created a time range slider (noUiSlider) programmatically. 我已经以编程方式创建了一个时间范围滑块(noUiSlider)。

It's working fine except that, I'm NOT able to drag the slider handles (that is available as a default behaviour), in order to change the slider value(s). 它工作正常,除了,我无法拖动滑块手柄(默认行为),以便更改滑块值。

var noUiSlider = require('./js/nouislider');

var sliderDiv = document.createElement("div");
sliderDiv.id = "slider-"+soundElement.description;
var sliderElem: any = noUiSlider.create(sliderDiv, {
    start: [0, 50],
    tooltips: [true, true],
    behaviour: "tap-drag",
    connect: true,
    orientation: 'vertical',
    range: {
        min: 0,
        max: 100
    }
});
soundElementIframe.appendChild(sliderDiv);

I've not been able to figure out, why drag interaction is not working (while everything else like 'tap' is working fine). 我一直无法弄清楚为什么拖动交互无法正常工作(而其他所有类似“轻按”的工作都正常)。 I'd really appreciate any help around this. 我真的很感谢对此的任何帮助。

在此处输入图片说明

What I think is happening is that you create your slider, then when you append it, it loses its (default?) listeners. 我认为正在发生的事情是创建滑块,然后添加滑块时,它将丢失其(默认值)侦听器。 To avoid this, append your div then initialize the noUiSlider element. 为避免这种情况,请附加div, 然后初始化noUiSlider元素。

const sliderDiv = document.createElement('div');
soundElementIframe.appendChild(sliderDiv);
noUiSlider.create(sliderDiv, options);

If this still doesn't work, try reselecting the new appended sliderDiv element and passing that into the noUiSlider.create() method. 如果仍然sliderDiv ,请尝试重新选择新添加的sliderDiv元素,并将其传递给noUiSlider.create()方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM