StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
StackGenVis/frontend/node_modules/vue-bootstrap-slider/lib/form-slider.js

83 lines
2.0 KiB

4 years ago
import Slider from 'bootstrap-slider'
import camelCase from 'lodash/camelCase'
import snakeCase from 'lodash/snakeCase'
import throttle from 'lodash/throttle'
import props from './properties'
import watch from './watchers'
// @vue/component
export default {
name: 'FormSlider',
props,
data() {
return {
slider: null,
lastEvent: {}
}
},
watch,
mounted() {
const props = {}
for (const key in this.$props) {
if (this.$props.hasOwnProperty(key)) {
const propskey = key === 'rangeHighlights' ? key : snakeCase(key)
props[propskey] = this.$props[key]
}
}
props.enabled = !this.disabled
this.slider = new Slider(this.$refs.input, props)
this.bindEvents()
},
beforeDestroy() {
if (this.slider) {
this.slider.destroy()
delete this.slider
}
},
methods: {
refresh: throttle(function () {
if (this.slider) {
this.slider.refresh({ useCurrentValue: true })
this.bindEvents()
}
}, 10),
bindEvents() {
const events = ['slide', 'slide-start', 'slide-stop', 'change', 'slide-enabled', 'slide-disabled']
events.forEach((event) => {
// only bind the event if the event is bound to us
if (event === 'change' || this.$listeners[event]) {
this.slider.on(camelCase(event), (value) => {
if (this.debounce > 0) {
const now = new Date().getTime()
if (this.lastEvent[event] !== null && now <= this.lastEvent[event] + this.debounce) {
return
}
this.lastEvent[event] = now
}
this.$emit(event, value)
if (event === 'change') {
this.$emit('input', value.newValue)
}
})
}
})
}
},
render(h) {
return h('div', {
staticClass: 'd-inline-block'
}, [
h('input', {
ref: 'input',
attrs: {
type: 'text'
}
})
])
}
}