Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/lib/HistogramSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ export default {
this.ionRangeSlider.update({ from, to })
this.updateBarColor({ from, to })
}
},
preventOverlap(e) {
const fromHandle = this.$el.querySelector('.irs-handle.from')
const toHandle = this.$el.querySelector('.irs-handle.to')
const handleSize = this.handleSize
const fromHandleLeftPosition = fromHandle.offsetLeft
const toHandleLeftPosition = toHandle.offsetLeft

if (fromHandleLeftPosition + handleSize <= toHandleLeftPosition) {
this.lastSliderHandleFromVal = e.from
this.lastSliderHandleToVal = e.to
} else {
this.update({
from: this.lastSliderHandleFromVal,
to: this.lastSliderHandleToVal
})
this.$emit('change', e)
}
}
},

Expand Down Expand Up @@ -192,6 +210,9 @@ export default {
if (this.updateColorOnChange) {
this.updateBarColor(val)
}
if (this.preventHandlesOverlap) {
return this.preventOverlap(val)
}
this.$emit('change', val)
}
})
Expand Down
4 changes: 4 additions & 0 deletions src/lib/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export default {
type: Boolean,
default: false
},
preventHandlesOverlap: {
type: Boolean,
default: false
},
grid: {
type: Boolean,
default: true
Expand Down