feat(tui): add managed config interface
This commit is contained in:
parent
1e17202413
commit
3568dd1b99
52 changed files with 848 additions and 266 deletions
|
|
@ -1,8 +1,10 @@
|
|||
import { MacOSScrollAccel, type ScrollAcceleration } from "@opentui/core"
|
||||
|
||||
export type ScrollConfig = {
|
||||
scroll_acceleration?: { enabled?: boolean }
|
||||
scroll_speed?: number
|
||||
scroll?: {
|
||||
acceleration?: boolean
|
||||
speed?: number
|
||||
}
|
||||
}
|
||||
|
||||
export class CustomSpeedScroll implements ScrollAcceleration {
|
||||
|
|
@ -16,11 +18,11 @@ export class CustomSpeedScroll implements ScrollAcceleration {
|
|||
}
|
||||
|
||||
export function getScrollAcceleration(tuiConfig?: ScrollConfig): ScrollAcceleration {
|
||||
if (tuiConfig?.scroll_acceleration?.enabled) {
|
||||
if (tuiConfig?.scroll?.acceleration) {
|
||||
return new MacOSScrollAccel()
|
||||
}
|
||||
if (tuiConfig?.scroll_speed !== undefined) {
|
||||
return new CustomSpeedScroll(tuiConfig.scroll_speed)
|
||||
if (tuiConfig?.scroll?.speed !== undefined) {
|
||||
return new CustomSpeedScroll(tuiConfig.scroll.speed)
|
||||
}
|
||||
|
||||
return new CustomSpeedScroll(3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue