如何使 noUiSlider 滑块重叠另一个滑块

huangapple go评论140阅读模式
英文:

How to Make noUiSlider Handle Overlap Another

问题

I have noUiSlider range slider with 3 handles, how to make one handle (in this example the blue handle in the center) can overlap another handle? I mean the blue handle movement is not limited by another handle position. Is that possible with noUiSlider?

我有一个带有3个手柄的noUiSlider范围滑块,如何使一个手柄(在这个示例中是中间的蓝色手柄)可以重叠另一个手柄?我的意思是蓝色手柄的移动不受另一个手柄位置的限制。这在noUiSlider中是否可能?

英文:

I have noUiSlider range slider with 3 handles, how to make one handle (in this example the blue handle in the center) can overlap another handle? I mean the blue handle movement is not limited by another handle position. Is that possible with noUiSlider?

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

var slider = document.getElementById(&#39;slider&#39;);

noUiSlider.create(slider, {
            start: [30, 50, 75],
            step: 1,
            range: {
                &#39;min&#39;: 0,
                &#39;max&#39;: 100
            },
            connect: true,
            handleAttributes: [{
                        &#39;class&#39;: &#39;noUi-handle&#39;
                    },
                    {
                        &#39;class&#39;: &#39;noUi-handle center-post&#39;
                    },
                    {
                        &#39;class&#39;: &#39;noUi-handle&#39;
                    }
                ],
        });

<!-- language: lang-html -->

&lt;link href=&quot;https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.7.1/nouislider.min.css&quot; rel=&quot;stylesheet&quot;/&gt;
&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.7.1/nouislider.min.js&quot;&gt;&lt;/script&gt;
&lt;div id=&quot;slider&quot;&gt;&lt;/div&gt;
&lt;style&gt;
.center-post {
  background: #21A1FF;
  border: 1px solid #21A1FF;
  box-shadow: inset 0 0 1px #21A1FF,inset 0 1px 7px #21A1FF,0 3px 6px -3px #21A1FF;
}
&lt;/style&gt;

<!-- end snippet -->

Thanks

答案1

得分: 1

要允许任何把手通过(例如不受限制),您可以传递 behaviour: 'unconstrained' 选项。例如:

var slider = document.getElementById("slider");

noUiSlider.create(slider, {
  start: [30, 50, 75],
  step: 1,
  range: {
    min: 0,
    max: 100
  },
  connect: true,
  behaviour: "unconstrained", // 添加
  handleAttributes: [
    {
      class: "noUi-handle"
    },
    {
      class: "noUi-handle center-post"
    },
    {
      class: "noUi-handle"
    }
  ]
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.7.1/nouislider.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.7.1/nouislider.min.js"></script>

<div id="slider"></div>

<style>
.center-post {
  background: #21A1FF;
  border: 1px solid #21A1FF;
  box-shadow: inset 0 0 1px #21A1FF,inset 0 1px 7px #21A1FF,0 3px 6px -3px #21A1FF;
}
</style>

请注意,代码部分已经被忽略,只返回翻译好的内容。

英文:

To allow any handle to pass (e.g. not be limited by) other handles, you can pass the behaviour: &#39;unconstrained&#39; option. For example:

<!-- begin snippet: js hide: false console: true babel: null -->

<!-- language: lang-js -->

var slider = document.getElementById("slider");

noUiSlider.create(slider, {
start: [30, 50, 75],
step: 1,
range: {
min: 0,
max: 100
},
connect: true,
behaviour: "unconstrained", // Added
handleAttributes: [
{
class: "noUi-handle"
},
{
class: "noUi-handle center-post"
},
{
class: "noUi-handle"
}
]
});

<!-- language: lang-html -->

&lt;link href=&quot;https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.7.1/nouislider.min.css&quot; rel=&quot;stylesheet&quot;/&gt;
&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.7.1/nouislider.min.js&quot;&gt;&lt;/script&gt;
&lt;div id=&quot;slider&quot;&gt;&lt;/div&gt;
&lt;style&gt;
.center-post {
  background: #21A1FF;
  border: 1px solid #21A1FF;
  box-shadow: inset 0 0 1px #21A1FF,inset 0 1px 7px #21A1FF,0 3px 6px -3px #21A1FF;
}
&lt;/style&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年7月10日 11:57:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76650605.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定