refactor(server): canonicalize service API (#31049)
This commit is contained in:
parent
53ff1b57c9
commit
fe0c4f8c74
388 changed files with 7075 additions and 4064 deletions
27
packages/tui/src/util/scroll.ts
Normal file
27
packages/tui/src/util/scroll.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { MacOSScrollAccel, type ScrollAcceleration } from "@opentui/core"
|
||||
|
||||
export type ScrollConfig = {
|
||||
scroll_acceleration?: { enabled?: boolean }
|
||||
scroll_speed?: number
|
||||
}
|
||||
|
||||
export class CustomSpeedScroll implements ScrollAcceleration {
|
||||
constructor(private speed: number) {}
|
||||
|
||||
tick(_now?: number): number {
|
||||
return this.speed
|
||||
}
|
||||
|
||||
reset(): void {}
|
||||
}
|
||||
|
||||
export function getScrollAcceleration(tuiConfig?: ScrollConfig): ScrollAcceleration {
|
||||
if (tuiConfig?.scroll_acceleration?.enabled) {
|
||||
return new MacOSScrollAccel()
|
||||
}
|
||||
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