@causyne/agent 1.20.53 → 1.20.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/tui/codeStreamRenderer.js +16 -2
- package/src/tui/codeStreamRenderer.ts +23 -3
- package/src/tui/prompt.js +2 -2
- package/src/tui/scrollInteraction.js +93 -5
- package/src/tui/scrollInteraction.ts +113 -5
- package/src/tui/viewport.js +6 -0
- package/src/tui/viewport.ts +7 -0
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { ChatRenderer } from './chatRenderer.js';
|
|
|
2
2
|
import { CODE_PANEL_LINES, codePreviewLineCount, defaultPreviewStart, renderCodeProgress } from './codeProgress.js';
|
|
3
3
|
import { calculateThinkingLineCount, DEFAULT_MAX_EXPANDED_LINES } from './thinkingBox.js';
|
|
4
4
|
import { markerAt } from './messageInteraction.js';
|
|
5
|
+
import { AdaptiveWheelDampener } from './scrollInteraction.js';
|
|
5
6
|
function lastStart(event) {
|
|
6
7
|
return Math.max(0, codePreviewLineCount(event) - CODE_PANEL_LINES);
|
|
7
8
|
}
|
|
@@ -32,7 +33,13 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
32
33
|
const limit = lastStart(state.event);
|
|
33
34
|
if (limit === 0)
|
|
34
35
|
return false;
|
|
35
|
-
|
|
36
|
+
if (!state.dampener) {
|
|
37
|
+
state.dampener = new AdaptiveWheelDampener();
|
|
38
|
+
}
|
|
39
|
+
const delta = state.dampener.stepRows(wheel.direction, 3);
|
|
40
|
+
if (delta === 0)
|
|
41
|
+
return true;
|
|
42
|
+
const next = Math.max(0, Math.min(limit, state.start + (wheel.direction === 'up' ? -delta : delta)));
|
|
36
43
|
if (next === state.start)
|
|
37
44
|
return true;
|
|
38
45
|
state.start = next;
|
|
@@ -65,8 +72,15 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
65
72
|
const limit = Math.max(0, totalLines - DEFAULT_MAX_EXPANDED_LINES);
|
|
66
73
|
if (limit === 0)
|
|
67
74
|
return false;
|
|
75
|
+
if (!frame.meta._dampener) {
|
|
76
|
+
frame.meta._dampener = new AdaptiveWheelDampener();
|
|
77
|
+
}
|
|
78
|
+
const dampener = frame.meta._dampener;
|
|
79
|
+
const delta = dampener.stepRows(wheel.direction, 3);
|
|
80
|
+
if (delta === 0)
|
|
81
|
+
return true;
|
|
68
82
|
const currentStart = Number(frame.meta.scrollStart) || 0;
|
|
69
|
-
const next = Math.max(0, Math.min(limit, currentStart + (wheel.direction === 'up' ? -
|
|
83
|
+
const next = Math.max(0, Math.min(limit, currentStart + (wheel.direction === 'up' ? -delta : delta)));
|
|
70
84
|
if (next === currentStart)
|
|
71
85
|
return true;
|
|
72
86
|
frame.meta.scrollStart = next;
|
|
@@ -2,9 +2,16 @@ import { ChatRenderer } from './chatRenderer.js';
|
|
|
2
2
|
import { CODE_PANEL_LINES, codePreviewLineCount, defaultPreviewStart, renderCodeProgress, type CodeProgressEvent } from './codeProgress.js';
|
|
3
3
|
import { calculateThinkingLineCount, DEFAULT_MAX_EXPANDED_LINES } from './thinkingBox.js';
|
|
4
4
|
import { markerAt } from './messageInteraction.js';
|
|
5
|
+
import { AdaptiveWheelDampener } from './scrollInteraction.js';
|
|
5
6
|
|
|
6
7
|
type RendererEvent = { type: string; [key: string]: unknown };
|
|
7
|
-
type CodePanelState = {
|
|
8
|
+
type CodePanelState = {
|
|
9
|
+
event: CodeProgressEvent;
|
|
10
|
+
modelNote: string;
|
|
11
|
+
start: number;
|
|
12
|
+
followTail: boolean;
|
|
13
|
+
dampener?: AdaptiveWheelDampener;
|
|
14
|
+
};
|
|
8
15
|
type CodeFrame = { id: number; meta?: Record<string, unknown> | null; rows?: string[] | null; renderedWidth?: number; produce?: (width: number) => string[] };
|
|
9
16
|
type CodeTranscript = {
|
|
10
17
|
frames: CodeFrame[];
|
|
@@ -50,7 +57,13 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
50
57
|
const limit = lastStart(state.event);
|
|
51
58
|
if (limit === 0) return false;
|
|
52
59
|
|
|
53
|
-
|
|
60
|
+
if (!state.dampener) {
|
|
61
|
+
state.dampener = new AdaptiveWheelDampener();
|
|
62
|
+
}
|
|
63
|
+
const delta = state.dampener.stepRows(wheel.direction as 'up' | 'down', 3);
|
|
64
|
+
if (delta === 0) return true;
|
|
65
|
+
|
|
66
|
+
const next = Math.max(0, Math.min(limit, state.start + (wheel.direction === 'up' ? -delta : delta)));
|
|
54
67
|
if (next === state.start) return true;
|
|
55
68
|
|
|
56
69
|
state.start = next;
|
|
@@ -82,8 +95,15 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
82
95
|
const limit = Math.max(0, totalLines - DEFAULT_MAX_EXPANDED_LINES);
|
|
83
96
|
if (limit === 0) return false;
|
|
84
97
|
|
|
98
|
+
if (!frame.meta._dampener) {
|
|
99
|
+
frame.meta._dampener = new AdaptiveWheelDampener();
|
|
100
|
+
}
|
|
101
|
+
const dampener = frame.meta._dampener as AdaptiveWheelDampener;
|
|
102
|
+
const delta = dampener.stepRows(wheel.direction as 'up' | 'down', 3);
|
|
103
|
+
if (delta === 0) return true;
|
|
104
|
+
|
|
85
105
|
const currentStart = Number(frame.meta.scrollStart) || 0;
|
|
86
|
-
const next = Math.max(0, Math.min(limit, currentStart + (wheel.direction === 'up' ? -
|
|
106
|
+
const next = Math.max(0, Math.min(limit, currentStart + (wheel.direction === 'up' ? -delta : delta)));
|
|
87
107
|
if (next === currentStart) return true;
|
|
88
108
|
|
|
89
109
|
frame.meta.scrollStart = next;
|
package/src/tui/prompt.js
CHANGED
|
@@ -920,11 +920,11 @@ export class ChatPrompt {
|
|
|
920
920
|
if (key.name === 'wheel') {
|
|
921
921
|
if (!viewport || !key.wheel) return true;
|
|
922
922
|
if (this.renderer?.scrollCodePanel?.(key, this.surface)) {
|
|
923
|
-
this.draw();
|
|
923
|
+
if (typeof this.scheduleDraw === 'function') this.scheduleDraw(); else this.draw();
|
|
924
924
|
return true;
|
|
925
925
|
}
|
|
926
926
|
if (this.renderer?.scrollThinkingPanel?.(key, this.surface)) {
|
|
927
|
-
this.draw();
|
|
927
|
+
if (typeof this.scheduleDraw === 'function') this.scheduleDraw(); else this.draw();
|
|
928
928
|
return true;
|
|
929
929
|
}
|
|
930
930
|
|
|
@@ -7,13 +7,95 @@
|
|
|
7
7
|
// preventing terminal scrollback desync and UI freezes.
|
|
8
8
|
// 4. Scrollbar (rail) mouse interactions clamp cleanly even if clicked above or
|
|
9
9
|
// below the chat box bounds.
|
|
10
|
+
/**
|
|
11
|
+
* Adaptive Wheel Dampener & Momentum Controller.
|
|
12
|
+
*
|
|
13
|
+
* Distinguishes single mechanical mouse wheel notches (e.g. 1 notch every 100ms+)
|
|
14
|
+
* from high-frequency macOS trackpad / Magic Mouse continuous event streams (10-100Hz).
|
|
15
|
+
*
|
|
16
|
+
* For single notches, full discrete step is preserved.
|
|
17
|
+
* For continuous trackpad streams, velocity is smoothly damped via sub-line accumulation
|
|
18
|
+
* so a natural finger swipe advances smoothly without exploding into runaway flight.
|
|
19
|
+
* Direction reversals provide instant braking to prevent momentum drift.
|
|
20
|
+
*/
|
|
21
|
+
export class AdaptiveWheelDampener {
|
|
22
|
+
minDamping;
|
|
23
|
+
thresholdMs;
|
|
24
|
+
minTickInterval;
|
|
25
|
+
burstWindowMs;
|
|
26
|
+
maxBurstNotches;
|
|
27
|
+
lastTick = 0;
|
|
28
|
+
lastDirection = null;
|
|
29
|
+
rowAccumulator = 0;
|
|
30
|
+
recentBursts = [];
|
|
31
|
+
constructor(options = {}) {
|
|
32
|
+
this.minDamping = options.minDamping ?? 0.28;
|
|
33
|
+
this.thresholdMs = options.thresholdMs ?? 85;
|
|
34
|
+
this.minTickInterval = options.minTickInterval ?? 6;
|
|
35
|
+
this.burstWindowMs = options.burstWindowMs ?? 120;
|
|
36
|
+
this.maxBurstNotches = options.maxBurstNotches ?? 5.0;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Compute adaptive fractional notch multiplier for viewports that possess
|
|
40
|
+
* their own sub-row accumulator (e.g. Viewport).
|
|
41
|
+
*/
|
|
42
|
+
computeNotches(direction, now = Date.now()) {
|
|
43
|
+
if (this.lastDirection && this.lastDirection !== direction) {
|
|
44
|
+
this.recentBursts = [];
|
|
45
|
+
this.lastTick = 0;
|
|
46
|
+
this.rowAccumulator = 0;
|
|
47
|
+
}
|
|
48
|
+
this.lastDirection = direction;
|
|
49
|
+
const gap = this.lastTick ? Math.max(0, now - this.lastTick) : Infinity;
|
|
50
|
+
this.lastTick = now;
|
|
51
|
+
if (gap === Infinity || gap > 150) {
|
|
52
|
+
this.recentBursts = [];
|
|
53
|
+
return 1.0;
|
|
54
|
+
}
|
|
55
|
+
if (gap < this.minTickInterval) {
|
|
56
|
+
return 1.0;
|
|
57
|
+
}
|
|
58
|
+
let damping = Math.max(this.minDamping, Math.min(1.0, gap / this.thresholdMs));
|
|
59
|
+
const windowStart = now - this.burstWindowMs;
|
|
60
|
+
this.recentBursts = this.recentBursts.filter(b => b.time >= windowStart);
|
|
61
|
+
const windowNotches = this.recentBursts.reduce((sum, b) => sum + b.notches, 0);
|
|
62
|
+
if (windowNotches >= this.maxBurstNotches) {
|
|
63
|
+
damping = Math.min(damping, 0.15);
|
|
64
|
+
}
|
|
65
|
+
this.recentBursts.push({ time: now, notches: damping });
|
|
66
|
+
return damping;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Compute whole integer row steps for widgets without internal sub-row accumulators
|
|
70
|
+
* (e.g. Code panel and Thinking box previews).
|
|
71
|
+
*/
|
|
72
|
+
stepRows(direction, baseSpeed = 3, now = Date.now()) {
|
|
73
|
+
const notch = this.computeNotches(direction, now);
|
|
74
|
+
this.rowAccumulator += baseSpeed * notch;
|
|
75
|
+
const whole = Math.trunc(this.rowAccumulator);
|
|
76
|
+
if (whole !== 0) {
|
|
77
|
+
this.rowAccumulator -= whole;
|
|
78
|
+
return whole;
|
|
79
|
+
}
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
reset() {
|
|
83
|
+
this.lastTick = 0;
|
|
84
|
+
this.lastDirection = null;
|
|
85
|
+
this.rowAccumulator = 0;
|
|
86
|
+
this.recentBursts = [];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export const defaultViewportDampener = new AdaptiveWheelDampener();
|
|
10
90
|
/**
|
|
11
91
|
* Handle mouse wheel scrolling with full viewport containment.
|
|
12
92
|
* Replaces the buggy overscroll release with clean boundary saturation.
|
|
13
93
|
*/
|
|
14
|
-
export function handleViewportWheel(key, viewport, surface, host) {
|
|
94
|
+
export function handleViewportWheel(key, viewport, surface, host, now = Date.now()) {
|
|
15
95
|
if (!viewport || !key.wheel)
|
|
16
96
|
return true;
|
|
97
|
+
if (key.wheel.direction !== 'up' && key.wheel.direction !== 'down')
|
|
98
|
+
return true;
|
|
17
99
|
// Auto-heal: If the surface was ever detached, immediately re-capture mouse
|
|
18
100
|
// so the session stays responsive and never freezes.
|
|
19
101
|
if (surface && typeof surface.captureMouse === 'function' && surface.detached) {
|
|
@@ -26,10 +108,16 @@ export function handleViewportWheel(key, viewport, surface, host) {
|
|
|
26
108
|
if (surface) {
|
|
27
109
|
surface.activeTurnIndex = null;
|
|
28
110
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
111
|
+
const dir = key.wheel.direction === 'down' ? 'down' : 'up';
|
|
112
|
+
const notches = defaultViewportDampener.computeNotches(dir, now);
|
|
113
|
+
viewport.wheel(dir, notches, now);
|
|
114
|
+
// Coalesce redraws to prevent terminal buffer flooding and latency pileup
|
|
115
|
+
if (typeof host.scheduleDraw === 'function') {
|
|
116
|
+
host.scheduleDraw();
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
host.draw();
|
|
120
|
+
}
|
|
33
121
|
return true;
|
|
34
122
|
}
|
|
35
123
|
/**
|
|
@@ -79,6 +79,107 @@ export interface PromptScrollHost {
|
|
|
79
79
|
} | null;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
export interface WheelDampenerOptions {
|
|
83
|
+
minDamping?: number;
|
|
84
|
+
thresholdMs?: number;
|
|
85
|
+
minTickInterval?: number;
|
|
86
|
+
burstWindowMs?: number;
|
|
87
|
+
maxBurstNotches?: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Adaptive Wheel Dampener & Momentum Controller.
|
|
92
|
+
*
|
|
93
|
+
* Distinguishes single mechanical mouse wheel notches (e.g. 1 notch every 100ms+)
|
|
94
|
+
* from high-frequency macOS trackpad / Magic Mouse continuous event streams (10-100Hz).
|
|
95
|
+
*
|
|
96
|
+
* For single notches, full discrete step is preserved.
|
|
97
|
+
* For continuous trackpad streams, velocity is smoothly damped via sub-line accumulation
|
|
98
|
+
* so a natural finger swipe advances smoothly without exploding into runaway flight.
|
|
99
|
+
* Direction reversals provide instant braking to prevent momentum drift.
|
|
100
|
+
*/
|
|
101
|
+
export class AdaptiveWheelDampener {
|
|
102
|
+
readonly minDamping: number;
|
|
103
|
+
readonly thresholdMs: number;
|
|
104
|
+
readonly minTickInterval: number;
|
|
105
|
+
readonly burstWindowMs: number;
|
|
106
|
+
readonly maxBurstNotches: number;
|
|
107
|
+
private lastTick = 0;
|
|
108
|
+
private lastDirection: 'up' | 'down' | null = null;
|
|
109
|
+
private rowAccumulator = 0;
|
|
110
|
+
private recentBursts: Array<{ time: number; notches: number }> = [];
|
|
111
|
+
|
|
112
|
+
constructor(options: WheelDampenerOptions = {}) {
|
|
113
|
+
this.minDamping = options.minDamping ?? 0.28;
|
|
114
|
+
this.thresholdMs = options.thresholdMs ?? 85;
|
|
115
|
+
this.minTickInterval = options.minTickInterval ?? 6;
|
|
116
|
+
this.burstWindowMs = options.burstWindowMs ?? 120;
|
|
117
|
+
this.maxBurstNotches = options.maxBurstNotches ?? 5.0;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Compute adaptive fractional notch multiplier for viewports that possess
|
|
122
|
+
* their own sub-row accumulator (e.g. Viewport).
|
|
123
|
+
*/
|
|
124
|
+
computeNotches(direction: 'up' | 'down', now: number = Date.now()): number {
|
|
125
|
+
if (this.lastDirection && this.lastDirection !== direction) {
|
|
126
|
+
this.recentBursts = [];
|
|
127
|
+
this.lastTick = 0;
|
|
128
|
+
this.rowAccumulator = 0;
|
|
129
|
+
}
|
|
130
|
+
this.lastDirection = direction;
|
|
131
|
+
|
|
132
|
+
const gap = this.lastTick ? Math.max(0, now - this.lastTick) : Infinity;
|
|
133
|
+
this.lastTick = now;
|
|
134
|
+
|
|
135
|
+
if (gap === Infinity || gap > 150) {
|
|
136
|
+
this.recentBursts = [];
|
|
137
|
+
return 1.0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (gap < this.minTickInterval) {
|
|
141
|
+
return 1.0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let damping = Math.max(this.minDamping, Math.min(1.0, gap / this.thresholdMs));
|
|
145
|
+
|
|
146
|
+
const windowStart = now - this.burstWindowMs;
|
|
147
|
+
this.recentBursts = this.recentBursts.filter(b => b.time >= windowStart);
|
|
148
|
+
const windowNotches = this.recentBursts.reduce((sum, b) => sum + b.notches, 0);
|
|
149
|
+
|
|
150
|
+
if (windowNotches >= this.maxBurstNotches) {
|
|
151
|
+
damping = Math.min(damping, 0.15);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.recentBursts.push({ time: now, notches: damping });
|
|
155
|
+
return damping;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Compute whole integer row steps for widgets without internal sub-row accumulators
|
|
160
|
+
* (e.g. Code panel and Thinking box previews).
|
|
161
|
+
*/
|
|
162
|
+
stepRows(direction: 'up' | 'down', baseSpeed: number = 3, now: number = Date.now()): number {
|
|
163
|
+
const notch = this.computeNotches(direction, now);
|
|
164
|
+
this.rowAccumulator += baseSpeed * notch;
|
|
165
|
+
const whole = Math.trunc(this.rowAccumulator);
|
|
166
|
+
if (whole !== 0) {
|
|
167
|
+
this.rowAccumulator -= whole;
|
|
168
|
+
return whole;
|
|
169
|
+
}
|
|
170
|
+
return 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
reset(): void {
|
|
174
|
+
this.lastTick = 0;
|
|
175
|
+
this.lastDirection = null;
|
|
176
|
+
this.rowAccumulator = 0;
|
|
177
|
+
this.recentBursts = [];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export const defaultViewportDampener = new AdaptiveWheelDampener();
|
|
182
|
+
|
|
82
183
|
/**
|
|
83
184
|
* Handle mouse wheel scrolling with full viewport containment.
|
|
84
185
|
* Replaces the buggy overscroll release with clean boundary saturation.
|
|
@@ -87,9 +188,11 @@ export function handleViewportWheel(
|
|
|
87
188
|
key: KeyEvent,
|
|
88
189
|
viewport: ViewportContract | null | undefined,
|
|
89
190
|
surface: SurfaceContract | null | undefined,
|
|
90
|
-
host: PromptScrollHost
|
|
191
|
+
host: PromptScrollHost,
|
|
192
|
+
now: number = Date.now()
|
|
91
193
|
): boolean {
|
|
92
194
|
if (!viewport || !key.wheel) return true;
|
|
195
|
+
if (key.wheel.direction !== 'up' && key.wheel.direction !== 'down') return true;
|
|
93
196
|
|
|
94
197
|
// Auto-heal: If the surface was ever detached, immediately re-capture mouse
|
|
95
198
|
// so the session stays responsive and never freezes.
|
|
@@ -105,11 +208,16 @@ export function handleViewportWheel(
|
|
|
105
208
|
(surface as any).activeTurnIndex = null;
|
|
106
209
|
}
|
|
107
210
|
|
|
108
|
-
|
|
109
|
-
|
|
211
|
+
const dir: 'up' | 'down' = key.wheel.direction === 'down' ? 'down' : 'up';
|
|
212
|
+
const notches = defaultViewportDampener.computeNotches(dir, now);
|
|
213
|
+
viewport.wheel(dir, notches, now);
|
|
110
214
|
|
|
111
|
-
//
|
|
112
|
-
host.
|
|
215
|
+
// Coalesce redraws to prevent terminal buffer flooding and latency pileup
|
|
216
|
+
if (typeof host.scheduleDraw === 'function') {
|
|
217
|
+
host.scheduleDraw();
|
|
218
|
+
} else {
|
|
219
|
+
host.draw();
|
|
220
|
+
}
|
|
113
221
|
return true;
|
|
114
222
|
}
|
|
115
223
|
|
package/src/tui/viewport.js
CHANGED
|
@@ -94,6 +94,7 @@ export class Viewport {
|
|
|
94
94
|
accumulator;
|
|
95
95
|
unseen;
|
|
96
96
|
lastWheelMoved;
|
|
97
|
+
lastWheelDirection;
|
|
97
98
|
constructor({ transcript = null, height = 20, width = 80, speed = DEFAULT_SCROLL_SPEED, acceleration = null } = {}) {
|
|
98
99
|
this.transcript = transcript;
|
|
99
100
|
this.viewHeight = Math.max(1, Math.floor(height));
|
|
@@ -106,6 +107,7 @@ export class Viewport {
|
|
|
106
107
|
this.accumulator = 0;
|
|
107
108
|
this.unseen = 0;
|
|
108
109
|
this.lastWheelMoved = false;
|
|
110
|
+
this.lastWheelDirection = null;
|
|
109
111
|
}
|
|
110
112
|
get height() { return this.viewHeight; }
|
|
111
113
|
get width() { return this.viewWidth; }
|
|
@@ -200,6 +202,10 @@ export class Viewport {
|
|
|
200
202
|
*/
|
|
201
203
|
wheel(direction, notches = 1, now = Date.now()) {
|
|
202
204
|
const before = this.scrollTop;
|
|
205
|
+
if (this.lastWheelDirection && this.lastWheelDirection !== direction) {
|
|
206
|
+
this.accumulator = 0;
|
|
207
|
+
}
|
|
208
|
+
this.lastWheelDirection = direction;
|
|
203
209
|
const multiplier = this.acceleration ? this.acceleration.tick(now) : 1;
|
|
204
210
|
const amount = Math.abs(notches) * this.speed * multiplier;
|
|
205
211
|
this.accumulator += direction === 'up' ? -amount : amount;
|
package/src/tui/viewport.ts
CHANGED
|
@@ -141,6 +141,7 @@ export class Viewport {
|
|
|
141
141
|
accumulator: number;
|
|
142
142
|
unseen: number;
|
|
143
143
|
lastWheelMoved: boolean;
|
|
144
|
+
lastWheelDirection: 'up' | 'down' | null;
|
|
144
145
|
|
|
145
146
|
constructor({
|
|
146
147
|
transcript = null,
|
|
@@ -161,6 +162,7 @@ export class Viewport {
|
|
|
161
162
|
this.accumulator = 0;
|
|
162
163
|
this.unseen = 0;
|
|
163
164
|
this.lastWheelMoved = false;
|
|
165
|
+
this.lastWheelDirection = null;
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
get height(): number { return this.viewHeight; }
|
|
@@ -261,6 +263,11 @@ export class Viewport {
|
|
|
261
263
|
*/
|
|
262
264
|
wheel(direction: 'up' | 'down', notches: number = 1, now: number = Date.now()): number {
|
|
263
265
|
const before = this.scrollTop;
|
|
266
|
+
if (this.lastWheelDirection && this.lastWheelDirection !== direction) {
|
|
267
|
+
this.accumulator = 0;
|
|
268
|
+
}
|
|
269
|
+
this.lastWheelDirection = direction;
|
|
270
|
+
|
|
264
271
|
const multiplier = this.acceleration ? this.acceleration.tick(now) : 1;
|
|
265
272
|
const amount = Math.abs(notches) * this.speed * multiplier;
|
|
266
273
|
this.accumulator += direction === 'up' ? -amount : amount;
|