如何在不触发 'update' 的情况下设置滑块值?

How do i set slider value without 'update' firering?

我希望能够在不触发更新事件的情况下设置滑块值。我尝试在 set 函数中设置第二个参数 (fireSetEvent),但这不起作用。

nouiContrast = document.getElementById('nouiContrast');
noUiSlider.create(nouiContrast, {
  start: 0,
  step: 0.01,
  behaviour: 'tap',
  connect: [true, false],
  range: {
    'min': 0,
    'max': 1
  }
});
nouiContrast.noUiSlider.on('update', function(values, handle) {
  applyFilterValue(6, 'contrast', values[handle]);
});

//....

nouiContrast.noUiSlider.set(val, false);

如果只想在用户拖动滑块时处理更新,而不是在代码设置更新时处理更新,可以监听slide事件。

来自文档:

This event is useful when you specifically want to listen to a handle being dragged, but want to ignore other updates to the slider value. This event also fires on a change by a 'tap'. In most cases, the update is the better choice.

nouiContrast = document.getElementById('nouiContrast');
noUiSlider.create(nouiContrast, {
  start: 0,
  step: 0.01,
  behaviour: 'tap',
  connect: [true, false],
  range: {
    'min': 0,
    'max': 1
  }
});
nouiContrast.noUiSlider.on('slide', function(values, handle) {
  applyFilterValue(6, 'contrast', values[handle]);
});

//....

nouiContrast.noUiSlider.set(val, false);