|
|
|
@ -1,16 +1,19 @@ |
|
|
|
import Property from './PropertyNumberView'; |
|
|
|
import PropertyNumber from '../model/PropertyNumber'; |
|
|
|
import PropertyNumberView from './PropertyNumberView'; |
|
|
|
|
|
|
|
export default class PropertySliderView extends PropertyNumberView { |
|
|
|
slider?: HTMLInputElement; |
|
|
|
|
|
|
|
export default class PropertySliderView extends Property { |
|
|
|
events() { |
|
|
|
return { |
|
|
|
...Property.prototype.events(), |
|
|
|
...PropertyNumberView.prototype.events(), |
|
|
|
'change [type=range]': 'inputValueChanged', |
|
|
|
'input [type=range]': 'inputValueChangedSoft', |
|
|
|
change: '', |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
templateInput(model) { |
|
|
|
templateInput(model: PropertyNumber) { |
|
|
|
const { ppfx } = this; |
|
|
|
return ` |
|
|
|
<div class="${ppfx}field ${ppfx}field-range"> |
|
|
|
@ -21,7 +24,7 @@ export default class PropertySliderView extends Property { |
|
|
|
|
|
|
|
getSliderEl() { |
|
|
|
if (!this.slider) { |
|
|
|
this.slider = this.el.querySelector('input[type=range]'); |
|
|
|
this.slider = this.el.querySelector('input[type=range]')!; |
|
|
|
} |
|
|
|
|
|
|
|
return this.slider; |
|
|
|
@ -35,23 +38,25 @@ export default class PropertySliderView extends Property { |
|
|
|
this.model.upValue(this.getSliderEl().value, { partial: true }); |
|
|
|
} |
|
|
|
|
|
|
|
setValue(value) { |
|
|
|
setValue(value: string) { |
|
|
|
const { model } = this; |
|
|
|
const parsed = model.parseValue(value); |
|
|
|
// @ts-ignore
|
|
|
|
this.getSliderEl().value = value === '' ? model.getDefaultValue() : parseFloat(parsed.value); |
|
|
|
Property.prototype.setValue.apply(this, arguments); |
|
|
|
PropertyNumberView.prototype.setValue.apply(this, arguments as any); |
|
|
|
} |
|
|
|
|
|
|
|
onRender() { |
|
|
|
Property.prototype.onRender.apply(this, arguments); |
|
|
|
PropertyNumberView.prototype.onRender.apply(this, arguments as any); |
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
if (!this.model.get('showInput')) { |
|
|
|
this.inputInst.el.style.display = 'none'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
clearCached() { |
|
|
|
Property.prototype.clearCached.apply(this, arguments); |
|
|
|
this.slider = null; |
|
|
|
PropertyNumberView.prototype.clearCached.apply(this, arguments as any); |
|
|
|
delete this.slider; |
|
|
|
} |
|
|
|
} |