Skip to content

Commit 1d5a986

Browse files
committed
more fixes to log scale flat slider
1 parent 748f958 commit 1d5a986

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

ui/src/app/modules/eqmac-components/components/flat-slider/flat-slider.component.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,20 @@ export class FlatSliderComponent {
137137
@HostListener('mousewheel', ['$event'])
138138
mouseWheel (event: MouseWheelEvent) {
139139
if (this.enabled && this.scrollEnabled) {
140-
const multiplier = (this.max - this.min) / 1000
141-
this.value = this._value + (-event.deltaY * multiplier)
140+
// const multiplier = (this.max - this.min) / 1000
141+
let progress = this.progress
142+
progress += -event.deltaY / 1000
143+
if (progress < 0) progress = 0
144+
if (progress > 1) progress = 1
145+
progress = Math.round(progress * 1000)
146+
this.value = this.mapValue({
147+
value: progress,
148+
inMin: 0,
149+
inMax: 1000,
150+
outMin: this.min,
151+
outMax: this.max,
152+
logInverse: false
153+
})
142154
this.userChangedValue.emit({ value: this._value })
143155
}
144156
}
@@ -229,13 +241,18 @@ export class FlatSliderComponent {
229241
}
230242

231243
get progress () {
232-
return this.mapValue({
244+
const factor = 10000
245+
let progress = this.mapValue({
233246
value: this.value,
234247
inMin: this.min,
235248
inMax: this.max,
236249
outMin: 0,
237-
outMax: 1
250+
outMax: factor,
251+
logInverse: true
238252
})
253+
254+
progress /= factor
255+
return progress
239256
}
240257

241258
get containerStyle () {
@@ -294,12 +311,7 @@ export class FlatSliderComponent {
294311

295312
style.borderRadius = '100%'
296313
const center = `calc(50% - ${this.thumbRadius}px)`
297-
// const centerOffset = `calc(50% - ${this.thumbRadius * 2}px)`
298-
// if (this.orientation === 'horizontal') {
299-
// style.left = centerOffset
300-
// } else {
301-
// style.top = centerOffset
302-
// }
314+
303315
style.top = center
304316
style.left = center
305317

0 commit comments

Comments
 (0)