Now.js Framework Documentation
RangeElementFactory
RangeElementFactory
EmbeddedRangeSlider A custom-built range slider, single or dual-handle, that replaces the native <input type="range"> for better keyboard and touch UX. Instantiated once per element by RangeElementFactory; the constructor moves the original input off-screen and renders the visible slider in its place.
หน้านี้สร้างจากซอร์สโดยตรงเมื่อ 2026-08-21 คำอธิบายมาจาก JSDoc ในไฟล์
รันซ้ำได้ด้วยdocs_scaffoldเมื่อโค้ดเปลี่ยน อย่าแก้ด้วยมือถ้าตั้งใจให้ generate ต่อ
ที่มา
- ไฟล์:
Now/js/RangeElementFactory.js(812 บรรทัด) - รูปแบบ: ES class
เมธอดสาธารณะ (11)
static createInstance(element, config = {})
Get or create the element's instance state, same as the base ElementFactory.
destroy()
Tear the slider down: disconnect its resize observer and remove its DOM.
getElement()
The wrapper element this slider rendered into.
getValue()
The slider's current value.
setDisabled(disabled)
Enable or disable the slider, including removing its handles from the tab order.
setMax(max)
Change the slider's maximum and update the handles' ARIA attributes to match.
setMin(min)
Change the slider's minimum and update the handles' ARIA attributes to match.
setReadonly(readonly)
Toggle read-only presentation without removing the slider from the tab order.
setStep(step)
Change the slider's step and refresh the display to match.
setValue(value)
Set the slider's value, snapping each number to the nearest step.
static setupElement(instance)
Replace the native range input with an EmbeddedRangeSlider.
เหตุการณ์
เหตุการณ์เหล่านี้เป็น DOM CustomEvent ที่ dispatch บนอีลิเมนต์ จึงต้องรับด้วย
element.addEventListener() และอ่านค่าจาก event.detail
| Event | เมื่อเกิด | event.detail |
|---|---|---|
rangeslider:input |
ลากตัวเลื่อน (ระหว่างลาก) | {values, min, max} |
rangeslider:change |
ปล่อยตัวเลื่อน | {values, min, max} |
element:change |
ค่าของ element เปลี่ยน | {elementId, values, type} |
Data attribute ที่ใช้
data-prefix · data-range · data-show-labels · data-show-tooltips · data-suffix
พึ่งพาคลาสอื่น
ColorElementFactory · ElementFactory · ElementManager · EventManager · FormManager · Utils