@acorex/cdk 22.4.47 → 22.4.49
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/fesm2022/acorex-cdk-outline.mjs +21 -11
- package/fesm2022/acorex-cdk-outline.mjs.map +1 -1
- package/fesm2022/acorex-cdk-overlay-scrollbar.mjs +1237 -329
- package/fesm2022/acorex-cdk-overlay-scrollbar.mjs.map +1 -1
- package/fesm2022/acorex-cdk-text-editor.mjs +2 -0
- package/fesm2022/acorex-cdk-text-editor.mjs.map +1 -1
- package/overlay-scrollbar/README.md +31 -31
- package/package.json +2 -2
- package/types/acorex-cdk-outline.d.ts +1 -0
- package/types/acorex-cdk-overlay-scrollbar.d.ts +157 -48
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { isPlatformBrowser, DOCUMENT } from '@angular/common';
|
|
2
1
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { InjectionToken,
|
|
2
|
+
import { InjectionToken, inject, ElementRef, DestroyRef, PLATFORM_ID, input, afterRenderEffect, effect, Directive, NgZone, Injectable, makeEnvironmentProviders, provideEnvironmentInitializer } from '@angular/core';
|
|
3
|
+
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
|
4
|
+
import { ScrollingModule } from '@angular/cdk/scrolling';
|
|
4
5
|
|
|
5
6
|
/** CSS custom properties for overlay scrollbar styling (set on the scroll host or in CSS). */
|
|
6
7
|
const AX_OVERLAY_SCROLLBAR_CSS_VARS = {
|
|
@@ -23,14 +24,24 @@ const AX_OVERLAY_SCROLLBAR_CSS_VARS = {
|
|
|
23
24
|
const AX_OVERLAY_SCROLLBAR_DEFAULT_HIDE_DELAY_MS = 800;
|
|
24
25
|
/** Default pixels scrolled per navigation arrow click. */
|
|
25
26
|
const AX_OVERLAY_SCROLLBAR_DEFAULT_NAV_SCROLL_STEP_PX = 40;
|
|
27
|
+
/**
|
|
28
|
+
* Defaults used by {@link overlayScrollbarConfig} / {@link provideOverlayScrollbar}.
|
|
29
|
+
* Calling the provider without `enabled` turns overlay scrollbars on.
|
|
30
|
+
*/
|
|
26
31
|
const AXOverlayScrollbarDefaultConfig = {
|
|
32
|
+
enabled: true,
|
|
27
33
|
hideDelay: AX_OVERLAY_SCROLLBAR_DEFAULT_HIDE_DELAY_MS,
|
|
28
34
|
navigationButtons: false,
|
|
29
35
|
navScrollStep: AX_OVERLAY_SCROLLBAR_DEFAULT_NAV_SCROLL_STEP_PX,
|
|
30
36
|
};
|
|
37
|
+
/** Config when {@link provideOverlayScrollbar} is not registered — native scrollbars stay intact. */
|
|
38
|
+
const AXOverlayScrollbarAbsentConfig = {
|
|
39
|
+
...AXOverlayScrollbarDefaultConfig,
|
|
40
|
+
enabled: false,
|
|
41
|
+
};
|
|
31
42
|
const AX_OVERLAY_SCROLLBAR_CONFIG = new InjectionToken('AX_OVERLAY_SCROLLBAR_CONFIG', {
|
|
32
43
|
providedIn: 'root',
|
|
33
|
-
factory: () =>
|
|
44
|
+
factory: () => AXOverlayScrollbarAbsentConfig,
|
|
34
45
|
});
|
|
35
46
|
const DESIGN_TOKEN_KEYS = {
|
|
36
47
|
size: AX_OVERLAY_SCROLLBAR_CSS_VARS.size,
|
|
@@ -50,71 +61,116 @@ const DESIGN_TOKEN_KEYS = {
|
|
|
50
61
|
/** Merges partial config with {@link AXOverlayScrollbarDefaultConfig}. */
|
|
51
62
|
function overlayScrollbarConfig(config = {}) {
|
|
52
63
|
const { designTokens, ...rest } = config;
|
|
53
|
-
|
|
64
|
+
const base = {
|
|
54
65
|
...AXOverlayScrollbarDefaultConfig,
|
|
55
66
|
...rest,
|
|
56
|
-
|
|
67
|
+
};
|
|
68
|
+
if (!designTokens) {
|
|
69
|
+
return base;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
...base,
|
|
73
|
+
designTokens: {
|
|
74
|
+
...AXOverlayScrollbarDefaultConfig.designTokens,
|
|
75
|
+
...designTokens,
|
|
76
|
+
},
|
|
57
77
|
};
|
|
58
78
|
}
|
|
59
|
-
/** Sets overlay scrollbar CSS variables on the given element. */
|
|
79
|
+
/** Sets overlay scrollbar CSS variables on the given element. Returns a snapshot for restore. */
|
|
60
80
|
function applyOverlayScrollbarDesignTokens(element, tokens) {
|
|
81
|
+
const snapshot = {};
|
|
61
82
|
if (!tokens) {
|
|
62
|
-
return;
|
|
83
|
+
return snapshot;
|
|
63
84
|
}
|
|
64
85
|
for (const key of Object.keys(DESIGN_TOKEN_KEYS)) {
|
|
65
86
|
const value = tokens[key];
|
|
66
|
-
if (value
|
|
67
|
-
|
|
87
|
+
if (value == null || value === '') {
|
|
88
|
+
continue;
|
|
68
89
|
}
|
|
90
|
+
const name = DESIGN_TOKEN_KEYS[key];
|
|
91
|
+
const previous = element.style.getPropertyValue(name);
|
|
92
|
+
snapshot[name] = previous
|
|
93
|
+
? { value: previous, priority: element.style.getPropertyPriority(name) }
|
|
94
|
+
: null;
|
|
95
|
+
element.style.setProperty(name, value);
|
|
69
96
|
}
|
|
97
|
+
return snapshot;
|
|
70
98
|
}
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*/
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
99
|
+
/** Restores CSS custom properties previously overwritten by {@link applyOverlayScrollbarDesignTokens}. */
|
|
100
|
+
function restoreOverlayScrollbarDesignTokens(element, snapshot) {
|
|
101
|
+
if (!snapshot) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
for (const [name, previous] of Object.entries(snapshot)) {
|
|
105
|
+
if (!previous) {
|
|
106
|
+
element.style.removeProperty(name);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
element.style.setProperty(name, previous.value, previous.priority);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const NATIVE_HIDE_CLASS = 'ax-cdk-overlay-scrollbar';
|
|
115
|
+
const STYLE_ELEMENT_ID = 'ax-overlay-scrollbar-styles';
|
|
116
|
+
let nativeHideRefCount = 0;
|
|
117
|
+
let styleRefCount = 0;
|
|
118
|
+
/** Hides native document scrollbars while at least one document-level overlay instance is active. */
|
|
119
|
+
function retainOverlayDocumentNativeHide(doc) {
|
|
120
|
+
nativeHideRefCount += 1;
|
|
121
|
+
if (nativeHideRefCount === 1) {
|
|
122
|
+
doc.documentElement.classList.add(NATIVE_HIDE_CLASS);
|
|
123
|
+
doc.body.classList.add(NATIVE_HIDE_CLASS);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function releaseOverlayDocumentNativeHide(doc) {
|
|
127
|
+
if (nativeHideRefCount === 0) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
nativeHideRefCount -= 1;
|
|
131
|
+
if (nativeHideRefCount === 0) {
|
|
132
|
+
doc.documentElement.classList.remove(NATIVE_HIDE_CLASS);
|
|
133
|
+
doc.body.classList.remove(NATIVE_HIDE_CLASS);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/** @internal Tests only. */
|
|
137
|
+
function resetOverlayDocumentNativeHideRefCount() {
|
|
138
|
+
nativeHideRefCount = 0;
|
|
139
|
+
}
|
|
140
|
+
/** Injects shared overlay scrollbar CSS once; last release removes the style node. */
|
|
141
|
+
function retainOverlayScrollbarStyles(doc, cssText) {
|
|
142
|
+
styleRefCount += 1;
|
|
143
|
+
const existing = doc.getElementById(STYLE_ELEMENT_ID);
|
|
144
|
+
if (existing) {
|
|
145
|
+
existing.textContent = cssText;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const style = doc.createElement('style');
|
|
149
|
+
style.id = STYLE_ELEMENT_ID;
|
|
150
|
+
style.textContent = cssText;
|
|
151
|
+
doc.head.appendChild(style);
|
|
152
|
+
}
|
|
153
|
+
function releaseOverlayScrollbarStyles(doc) {
|
|
154
|
+
if (styleRefCount === 0) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
styleRefCount -= 1;
|
|
158
|
+
if (styleRefCount === 0) {
|
|
159
|
+
doc.getElementById(STYLE_ELEMENT_ID)?.remove();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** @internal Tests only. */
|
|
163
|
+
function resetOverlayScrollbarStyleRefCount() {
|
|
164
|
+
styleRefCount = 0;
|
|
113
165
|
}
|
|
114
166
|
|
|
115
167
|
const OVERLAY_SCROLLBAR_TOKEN_NAMES = Object.values(AX_OVERLAY_SCROLLBAR_CSS_VARS);
|
|
116
168
|
const ROOT_CLASS = 'ax-cdk-overlay-scrollbar-root';
|
|
169
|
+
const CONTAINING_BLOCK_CLASS = 'ax-cdk-overlay-scrollbar--containing-block';
|
|
117
170
|
const RAIL_CLASS = 'ax-cdk-overlay-scrollbar__rail';
|
|
171
|
+
const RAIL_VERTICAL_CLASS = 'ax-cdk-overlay-scrollbar__rail--vertical';
|
|
172
|
+
const RAIL_HORIZONTAL_CLASS = 'ax-cdk-overlay-scrollbar__rail--horizontal';
|
|
173
|
+
const DOCUMENT_RAIL_CLASS = 'ax-cdk-overlay-scrollbar__rail--document';
|
|
118
174
|
const TRACK_CLASS = 'ax-cdk-overlay-scrollbar__rail-track';
|
|
119
175
|
const THUMB_CLASS = 'ax-cdk-overlay-scrollbar__rail-thumb';
|
|
120
176
|
const NAV_BTN_CLASS = 'ax-cdk-overlay-scrollbar__nav-button';
|
|
@@ -128,38 +184,22 @@ const ENGAGED_CLASS = 'ax-cdk-overlay-scrollbar--engaged';
|
|
|
128
184
|
const TRACK_PRESSED_CLASS = 'ax-cdk-overlay-scrollbar--track-pressed';
|
|
129
185
|
const OVERLAY_SCROLLBAR_STYLES = `
|
|
130
186
|
.ax-cdk-overlay-scrollbar-root {
|
|
131
|
-
position: relative;
|
|
132
|
-
display: block;
|
|
133
187
|
min-height: 0;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
--ax-comp-overlay-scrollbar-thumb-radius: 4px;
|
|
137
|
-
--ax-comp-overlay-scrollbar-track-radius: 4px;
|
|
138
|
-
--ax-comp-overlay-scrollbar-track-color: transparent;
|
|
139
|
-
--ax-comp-overlay-scrollbar-thumb-color: var(--ax-sys-scroller-thumb-color, #64748b);
|
|
140
|
-
--ax-comp-overlay-scrollbar-thumb-border-width: 0;
|
|
141
|
-
--ax-comp-overlay-scrollbar-thumb-border-color: transparent;
|
|
142
|
-
--ax-comp-overlay-scrollbar-track-border-width: 0;
|
|
143
|
-
--ax-comp-overlay-scrollbar-track-border-color: transparent;
|
|
188
|
+
min-width: 0;
|
|
189
|
+
overflow-anchor: none;
|
|
144
190
|
}
|
|
145
191
|
|
|
146
192
|
.ax-cdk-overlay-scrollbar {
|
|
147
|
-
|
|
148
|
-
--ax-comp-overlay-scrollbar-size: 6px;
|
|
149
|
-
--ax-comp-overlay-scrollbar-fade-duration: 0.35s;
|
|
150
|
-
--ax-comp-overlay-scrollbar-thumb-radius: 4px;
|
|
151
|
-
--ax-comp-overlay-scrollbar-track-radius: 4px;
|
|
152
|
-
--ax-comp-overlay-scrollbar-track-color: transparent;
|
|
153
|
-
--ax-comp-overlay-scrollbar-thumb-color: var(--ax-sys-scroller-thumb-color, #64748b);
|
|
154
|
-
--ax-comp-overlay-scrollbar-thumb-border-width: 0;
|
|
155
|
-
--ax-comp-overlay-scrollbar-thumb-border-color: transparent;
|
|
156
|
-
--ax-comp-overlay-scrollbar-track-border-width: 0;
|
|
157
|
-
--ax-comp-overlay-scrollbar-track-border-color: transparent;
|
|
193
|
+
overflow-anchor: none;
|
|
158
194
|
|
|
159
195
|
scrollbar-width: none !important;
|
|
160
196
|
-ms-overflow-style: none;
|
|
161
197
|
}
|
|
162
198
|
|
|
199
|
+
.ax-cdk-overlay-scrollbar--containing-block {
|
|
200
|
+
position: relative;
|
|
201
|
+
}
|
|
202
|
+
|
|
163
203
|
.ax-cdk-overlay-scrollbar::-webkit-scrollbar {
|
|
164
204
|
display: none !important;
|
|
165
205
|
width: 0 !important;
|
|
@@ -170,14 +210,15 @@ const OVERLAY_SCROLLBAR_STYLES = `
|
|
|
170
210
|
.ax-cdk-overlay-scrollbar__rail {
|
|
171
211
|
position: absolute;
|
|
172
212
|
top: 0;
|
|
173
|
-
bottom:
|
|
213
|
+
bottom: auto;
|
|
174
214
|
inset-inline-end: 0;
|
|
175
215
|
width: var(--ax-comp-overlay-scrollbar-size, 6px);
|
|
176
|
-
overflow:
|
|
177
|
-
pointer-events:
|
|
216
|
+
overflow: visible;
|
|
217
|
+
pointer-events: none;
|
|
178
218
|
opacity: 0;
|
|
179
219
|
z-index: 10;
|
|
180
220
|
box-sizing: border-box;
|
|
221
|
+
overflow-anchor: none;
|
|
181
222
|
border-radius: var(--ax-comp-overlay-scrollbar-track-radius, 4px);
|
|
182
223
|
background-color: var(--ax-comp-overlay-scrollbar-track-color, transparent);
|
|
183
224
|
border-width: var(--ax-comp-overlay-scrollbar-track-border-width, 0);
|
|
@@ -188,25 +229,28 @@ const OVERLAY_SCROLLBAR_STYLES = `
|
|
|
188
229
|
background-color 0.15s ease;
|
|
189
230
|
}
|
|
190
231
|
|
|
191
|
-
.ax-cdk-overlay-scrollbar-root.ax-cdk-overlay-scrollbar--active .ax-cdk-overlay-scrollbar__rail,
|
|
192
|
-
.ax-cdk-overlay-scrollbar.ax-cdk-overlay-scrollbar--active .ax-cdk-overlay-scrollbar__rail
|
|
232
|
+
.ax-cdk-overlay-scrollbar-root.ax-cdk-overlay-scrollbar--active > .ax-cdk-overlay-scrollbar__rail,
|
|
233
|
+
.ax-cdk-overlay-scrollbar.ax-cdk-overlay-scrollbar--active > .ax-cdk-overlay-scrollbar__rail,
|
|
234
|
+
.ax-cdk-overlay-scrollbar__rail:hover {
|
|
193
235
|
opacity: 1;
|
|
236
|
+
pointer-events: auto;
|
|
194
237
|
}
|
|
195
238
|
|
|
196
239
|
.ax-cdk-overlay-scrollbar__rail-track {
|
|
197
240
|
position: absolute;
|
|
198
241
|
inset: 0;
|
|
199
242
|
box-sizing: border-box;
|
|
243
|
+
overflow: hidden;
|
|
200
244
|
}
|
|
201
245
|
|
|
202
246
|
.ax-cdk-overlay-scrollbar-root.ax-cdk-overlay-scrollbar--active.ax-cdk-overlay-scrollbar--track-pressed
|
|
203
|
-
.ax-cdk-overlay-scrollbar__rail,
|
|
247
|
+
> .ax-cdk-overlay-scrollbar__rail,
|
|
204
248
|
.ax-cdk-overlay-scrollbar.ax-cdk-overlay-scrollbar--active.ax-cdk-overlay-scrollbar--track-pressed
|
|
205
|
-
.ax-cdk-overlay-scrollbar__rail,
|
|
249
|
+
> .ax-cdk-overlay-scrollbar__rail,
|
|
206
250
|
.ax-cdk-overlay-scrollbar-root.ax-cdk-overlay-scrollbar--active.ax-cdk-overlay-scrollbar--engaged
|
|
207
|
-
.ax-cdk-overlay-scrollbar__rail,
|
|
251
|
+
> .ax-cdk-overlay-scrollbar__rail,
|
|
208
252
|
.ax-cdk-overlay-scrollbar.ax-cdk-overlay-scrollbar--active.ax-cdk-overlay-scrollbar--engaged
|
|
209
|
-
.ax-cdk-overlay-scrollbar__rail {
|
|
253
|
+
> .ax-cdk-overlay-scrollbar__rail {
|
|
210
254
|
background-color: var(
|
|
211
255
|
--ax-comp-overlay-scrollbar-track-active-color,
|
|
212
256
|
var(--ax-comp-overlay-scrollbar-track-color, transparent)
|
|
@@ -216,50 +260,83 @@ const OVERLAY_SCROLLBAR_STYLES = `
|
|
|
216
260
|
.ax-cdk-overlay-scrollbar__rail--with-nav {
|
|
217
261
|
display: flex;
|
|
218
262
|
flex-direction: column;
|
|
219
|
-
overflow:
|
|
263
|
+
overflow: visible;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.ax-cdk-overlay-scrollbar__rail--horizontal.ax-cdk-overlay-scrollbar__rail--with-nav {
|
|
267
|
+
flex-direction: row;
|
|
220
268
|
}
|
|
221
269
|
|
|
222
270
|
.ax-cdk-overlay-scrollbar__rail--with-nav .ax-cdk-overlay-scrollbar__rail-track {
|
|
223
271
|
position: relative;
|
|
224
272
|
flex: 1 1 auto;
|
|
225
273
|
min-height: 0;
|
|
274
|
+
min-width: 0;
|
|
226
275
|
inset: auto;
|
|
276
|
+
overflow: hidden;
|
|
227
277
|
}
|
|
228
278
|
|
|
229
279
|
.ax-cdk-overlay-scrollbar__nav-button {
|
|
280
|
+
--ax-overlay-nav-size: var(--ax-comp-overlay-scrollbar-size, 6px);
|
|
281
|
+
--ax-overlay-nav-arrow: max(2px, calc(var(--ax-overlay-nav-size) * 0.4));
|
|
230
282
|
display: none;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
283
|
+
position: relative;
|
|
284
|
+
z-index: 2;
|
|
285
|
+
flex: 0 0 var(--ax-overlay-nav-size);
|
|
286
|
+
width: var(--ax-overlay-nav-size);
|
|
287
|
+
height: var(--ax-overlay-nav-size);
|
|
288
|
+
min-width: 0;
|
|
289
|
+
min-height: 0;
|
|
234
290
|
margin: 0;
|
|
235
291
|
padding: 0;
|
|
236
292
|
border: none;
|
|
237
293
|
box-sizing: border-box;
|
|
238
|
-
cursor:
|
|
294
|
+
cursor: pointer;
|
|
239
295
|
align-items: center;
|
|
240
296
|
justify-content: center;
|
|
241
297
|
background-color: transparent;
|
|
242
298
|
color: var(--ax-comp-overlay-scrollbar-thumb-color, var(--ax-sys-scroller-thumb-color, #64748b));
|
|
299
|
+
pointer-events: auto;
|
|
300
|
+
touch-action: none;
|
|
243
301
|
}
|
|
244
302
|
|
|
245
303
|
.ax-cdk-overlay-scrollbar__rail--with-nav .ax-cdk-overlay-scrollbar__nav-button {
|
|
246
304
|
display: flex;
|
|
247
305
|
}
|
|
248
306
|
|
|
307
|
+
.ax-cdk-overlay-scrollbar__rail--horizontal .ax-cdk-overlay-scrollbar__nav-button {
|
|
308
|
+
width: var(--ax-overlay-nav-size);
|
|
309
|
+
height: var(--ax-overlay-nav-size);
|
|
310
|
+
}
|
|
311
|
+
|
|
249
312
|
.ax-cdk-overlay-scrollbar__nav-arrow {
|
|
250
313
|
width: 0;
|
|
251
314
|
height: 0;
|
|
252
|
-
border-left: 3px solid transparent;
|
|
253
|
-
border-right: 3px solid transparent;
|
|
254
315
|
pointer-events: none;
|
|
255
316
|
}
|
|
256
317
|
|
|
257
318
|
.ax-cdk-overlay-scrollbar__nav-arrow--up {
|
|
258
|
-
border-
|
|
319
|
+
border-left: var(--ax-overlay-nav-arrow) solid transparent;
|
|
320
|
+
border-right: var(--ax-overlay-nav-arrow) solid transparent;
|
|
321
|
+
border-bottom: calc(var(--ax-overlay-nav-arrow) * 1.2) solid currentColor;
|
|
259
322
|
}
|
|
260
323
|
|
|
261
324
|
.ax-cdk-overlay-scrollbar__nav-arrow--down {
|
|
262
|
-
border-
|
|
325
|
+
border-left: var(--ax-overlay-nav-arrow) solid transparent;
|
|
326
|
+
border-right: var(--ax-overlay-nav-arrow) solid transparent;
|
|
327
|
+
border-top: calc(var(--ax-overlay-nav-arrow) * 1.2) solid currentColor;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.ax-cdk-overlay-scrollbar__nav-arrow--start {
|
|
331
|
+
border-top: var(--ax-overlay-nav-arrow) solid transparent;
|
|
332
|
+
border-bottom: var(--ax-overlay-nav-arrow) solid transparent;
|
|
333
|
+
border-right: calc(var(--ax-overlay-nav-arrow) * 1.2) solid currentColor;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.ax-cdk-overlay-scrollbar__nav-arrow--end {
|
|
337
|
+
border-top: var(--ax-overlay-nav-arrow) solid transparent;
|
|
338
|
+
border-bottom: var(--ax-overlay-nav-arrow) solid transparent;
|
|
339
|
+
border-left: calc(var(--ax-overlay-nav-arrow) * 1.2) solid currentColor;
|
|
263
340
|
}
|
|
264
341
|
|
|
265
342
|
.ax-cdk-overlay-scrollbar__rail-thumb {
|
|
@@ -284,8 +361,8 @@ const OVERLAY_SCROLLBAR_STYLES = `
|
|
|
284
361
|
inset: -4px -8px;
|
|
285
362
|
}
|
|
286
363
|
|
|
287
|
-
.ax-cdk-overlay-scrollbar-root.ax-cdk-overlay-scrollbar--active .ax-cdk-overlay-scrollbar__rail-thumb:hover,
|
|
288
|
-
.ax-cdk-overlay-scrollbar.ax-cdk-overlay-scrollbar--active .ax-cdk-overlay-scrollbar__rail-thumb:hover {
|
|
364
|
+
.ax-cdk-overlay-scrollbar-root.ax-cdk-overlay-scrollbar--active > .ax-cdk-overlay-scrollbar__rail .ax-cdk-overlay-scrollbar__rail-thumb:hover,
|
|
365
|
+
.ax-cdk-overlay-scrollbar.ax-cdk-overlay-scrollbar--active > .ax-cdk-overlay-scrollbar__rail .ax-cdk-overlay-scrollbar__rail-thumb:hover {
|
|
289
366
|
background-color: var(
|
|
290
367
|
--ax-comp-overlay-scrollbar-thumb-hover-color,
|
|
291
368
|
var(
|
|
@@ -296,26 +373,84 @@ const OVERLAY_SCROLLBAR_STYLES = `
|
|
|
296
373
|
}
|
|
297
374
|
|
|
298
375
|
.ax-cdk-overlay-scrollbar-root.ax-cdk-overlay-scrollbar--active.ax-cdk-overlay-scrollbar--engaged
|
|
299
|
-
.ax-cdk-overlay-scrollbar__rail-thumb,
|
|
376
|
+
> .ax-cdk-overlay-scrollbar__rail .ax-cdk-overlay-scrollbar__rail-thumb,
|
|
300
377
|
.ax-cdk-overlay-scrollbar.ax-cdk-overlay-scrollbar--active.ax-cdk-overlay-scrollbar--engaged
|
|
301
|
-
.ax-cdk-overlay-scrollbar__rail-thumb,
|
|
378
|
+
> .ax-cdk-overlay-scrollbar__rail .ax-cdk-overlay-scrollbar__rail-thumb,
|
|
302
379
|
.ax-cdk-overlay-scrollbar-root.ax-cdk-overlay-scrollbar--active.ax-cdk-overlay-scrollbar--engaged
|
|
303
|
-
.ax-cdk-overlay-scrollbar__rail-thumb:hover,
|
|
380
|
+
> .ax-cdk-overlay-scrollbar__rail .ax-cdk-overlay-scrollbar__rail-thumb:hover,
|
|
304
381
|
.ax-cdk-overlay-scrollbar.ax-cdk-overlay-scrollbar--active.ax-cdk-overlay-scrollbar--engaged
|
|
305
|
-
.ax-cdk-overlay-scrollbar__rail-thumb:hover {
|
|
382
|
+
> .ax-cdk-overlay-scrollbar__rail .ax-cdk-overlay-scrollbar__rail-thumb:hover {
|
|
306
383
|
background-color: var(
|
|
307
384
|
--ax-comp-overlay-scrollbar-thumb-active-color,
|
|
308
385
|
var(--ax-comp-overlay-scrollbar-thumb-color, var(--ax-sys-scroller-thumb-color, #64748b))
|
|
309
386
|
);
|
|
310
387
|
}
|
|
388
|
+
|
|
389
|
+
html.ax-cdk-overlay-scrollbar,
|
|
390
|
+
html.ax-cdk-overlay-scrollbar body,
|
|
391
|
+
body.ax-cdk-overlay-scrollbar {
|
|
392
|
+
overflow-anchor: none;
|
|
393
|
+
scrollbar-width: none !important;
|
|
394
|
+
-ms-overflow-style: none;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
html.ax-cdk-overlay-scrollbar::-webkit-scrollbar,
|
|
398
|
+
html.ax-cdk-overlay-scrollbar body::-webkit-scrollbar,
|
|
399
|
+
body.ax-cdk-overlay-scrollbar::-webkit-scrollbar {
|
|
400
|
+
display: none !important;
|
|
401
|
+
width: 0 !important;
|
|
402
|
+
height: 0 !important;
|
|
403
|
+
background: transparent !important;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.ax-cdk-overlay-scrollbar__rail--horizontal {
|
|
407
|
+
top: auto;
|
|
408
|
+
bottom: 0;
|
|
409
|
+
inset-inline-end: auto;
|
|
410
|
+
inset-inline-start: 0;
|
|
411
|
+
width: auto;
|
|
412
|
+
height: var(--ax-comp-overlay-scrollbar-size, 6px);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
.ax-cdk-overlay-scrollbar__rail--horizontal .ax-cdk-overlay-scrollbar__rail-thumb {
|
|
416
|
+
top: 0;
|
|
417
|
+
width: auto;
|
|
418
|
+
height: 100%;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.ax-cdk-overlay-scrollbar__rail--horizontal .ax-cdk-overlay-scrollbar__rail-thumb::before {
|
|
422
|
+
inset: -8px -4px;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.ax-cdk-overlay-scrollbar__rail--document {
|
|
426
|
+
position: fixed;
|
|
427
|
+
top: 0;
|
|
428
|
+
bottom: auto;
|
|
429
|
+
height: 100dvh;
|
|
430
|
+
inset-inline-end: 0;
|
|
431
|
+
z-index: 2147483000;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
.ax-cdk-overlay-scrollbar__rail--document.ax-cdk-overlay-scrollbar__rail--horizontal {
|
|
435
|
+
top: auto;
|
|
436
|
+
bottom: 0;
|
|
437
|
+
inset-inline-start: 0;
|
|
438
|
+
inset-inline-end: auto;
|
|
439
|
+
width: 100vw;
|
|
440
|
+
height: var(--ax-comp-overlay-scrollbar-size, 6px);
|
|
441
|
+
}
|
|
311
442
|
`.trim();
|
|
312
|
-
const
|
|
443
|
+
const AX_OVERLAY_SCROLLBAR_HOST_INIT_ATTR = 'data-ax-overlay-scrollbar-host';
|
|
444
|
+
const HOST_INIT_ATTR = AX_OVERLAY_SCROLLBAR_HOST_INIT_ATTR;
|
|
313
445
|
const DEFAULT_HIDE_DELAY_MS = AX_OVERLAY_SCROLLBAR_DEFAULT_HIDE_DELAY_MS;
|
|
314
446
|
const MIN_SCROLLBAR_WIDTH_PX = 2;
|
|
315
447
|
const MAX_SCROLLBAR_WIDTH_PX = 32;
|
|
316
448
|
const DEFAULT_SCROLLBAR_WIDTH_PX = 6;
|
|
317
449
|
const MIN_THUMB_HEIGHT_PX = 20;
|
|
318
450
|
const DEFAULT_NAV_SCROLL_STEP_PX = AX_OVERLAY_SCROLLBAR_DEFAULT_NAV_SCROLL_STEP_PX;
|
|
451
|
+
const NAV_REPEAT_DELAY_MS = 350;
|
|
452
|
+
const NAV_REPEAT_INTERVAL_MS = 50;
|
|
453
|
+
const OVERLAY_SCROLLBAR_RUNTIMES = new WeakMap();
|
|
319
454
|
function clampOverlayScrollbarWidth(px) {
|
|
320
455
|
if (!Number.isFinite(px)) {
|
|
321
456
|
return DEFAULT_SCROLLBAR_WIDTH_PX;
|
|
@@ -323,15 +458,7 @@ function clampOverlayScrollbarWidth(px) {
|
|
|
323
458
|
return Math.min(MAX_SCROLLBAR_WIDTH_PX, Math.max(MIN_SCROLLBAR_WIDTH_PX, Math.round(px)));
|
|
324
459
|
}
|
|
325
460
|
function injectOverlayScrollbarStyles(document) {
|
|
326
|
-
|
|
327
|
-
if (existing) {
|
|
328
|
-
existing.textContent = OVERLAY_SCROLLBAR_STYLES;
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
const style = document.createElement('style');
|
|
332
|
-
style.id = STYLE_ELEMENT_ID;
|
|
333
|
-
style.textContent = OVERLAY_SCROLLBAR_STYLES;
|
|
334
|
-
document.head.appendChild(style);
|
|
461
|
+
retainOverlayScrollbarStyles(document, OVERLAY_SCROLLBAR_STYLES);
|
|
335
462
|
}
|
|
336
463
|
/** Rail is a sibling of the host; copy resolved tokens from the host so the rail can use them. */
|
|
337
464
|
function syncOverlayScrollbarDesignTokens(host, root) {
|
|
@@ -366,23 +493,29 @@ function readRailWidthPx(rail) {
|
|
|
366
493
|
return DEFAULT_SCROLLBAR_WIDTH_PX;
|
|
367
494
|
}
|
|
368
495
|
/**
|
|
369
|
-
*
|
|
370
|
-
*
|
|
496
|
+
* DOM overlay scrollbar that does not require an Angular view on the host.
|
|
497
|
+
* Used by {@link AXOverlayScrollbarDirective} and by {@link provideOverlayScrollbar} auto-attach.
|
|
371
498
|
*/
|
|
372
|
-
class
|
|
373
|
-
constructor() {
|
|
374
|
-
this.
|
|
375
|
-
this.
|
|
376
|
-
this.
|
|
377
|
-
this.
|
|
378
|
-
this.appConfig = inject(AX_OVERLAY_SCROLLBAR_CONFIG);
|
|
499
|
+
class AXOverlayScrollbarRuntime {
|
|
500
|
+
constructor(hostEl, document, config, options) {
|
|
501
|
+
this.hostEl = hostEl;
|
|
502
|
+
this.document = document;
|
|
503
|
+
this.config = config;
|
|
504
|
+
this.options = options;
|
|
379
505
|
this.rootEl = null;
|
|
380
506
|
this.railEl = null;
|
|
381
507
|
this.trackEl = null;
|
|
382
508
|
this.navUpEl = null;
|
|
383
509
|
this.navDownEl = null;
|
|
384
510
|
this.thumbEl = null;
|
|
511
|
+
this.xRailEl = null;
|
|
512
|
+
this.xTrackEl = null;
|
|
513
|
+
this.xThumbEl = null;
|
|
514
|
+
this.navStartEl = null;
|
|
515
|
+
this.navEndEl = null;
|
|
385
516
|
this.resizeObserver = null;
|
|
517
|
+
this.contentMutationObserver = null;
|
|
518
|
+
this.overflowRemeasureFrame = null;
|
|
386
519
|
this.designTokenMutationObserver = null;
|
|
387
520
|
this.designTokenSyncFrame = null;
|
|
388
521
|
this.thumbDragPointerId = null;
|
|
@@ -391,96 +524,224 @@ class AXOverlayScrollbarDirective {
|
|
|
391
524
|
this.unbindRailInteraction = null;
|
|
392
525
|
/** Thumb size derived from layout; position updates on scroll without re-measuring scrollHeight. */
|
|
393
526
|
this.thumbLayout = null;
|
|
394
|
-
this.
|
|
395
|
-
...(ngDevMode ? [{ debugName: "hideDelay" }] : /* istanbul ignore next */ []));
|
|
396
|
-
/**
|
|
397
|
-
* When true, shows browser-style up/down arrow buttons on the rail.
|
|
398
|
-
* Styling follows track/thumb CSS tokens.
|
|
399
|
-
*/
|
|
400
|
-
this.navigationButtons = input(this.appConfig.navigationButtons, /* @ts-ignore */
|
|
401
|
-
...(ngDevMode ? [{ debugName: "navigationButtons" }] : /* istanbul ignore next */ []));
|
|
402
|
-
/** Pixels to scroll per arrow click. */
|
|
403
|
-
this.navScrollStep = input(this.appConfig.navScrollStep, /* @ts-ignore */
|
|
404
|
-
...(ngDevMode ? [{ debugName: "navScrollStep" }] : /* istanbul ignore next */ []));
|
|
527
|
+
this.xThumbLayout = null;
|
|
405
528
|
this.hideTimer = null;
|
|
406
|
-
|
|
407
|
-
|
|
529
|
+
this.navRepeatDelayTimer = null;
|
|
530
|
+
this.navRepeatTimer = null;
|
|
531
|
+
this.scrollIdleTimer = null;
|
|
532
|
+
this.isScrolling = false;
|
|
533
|
+
this.pendingRemeasure = false;
|
|
534
|
+
/** When true, native scrollbars are hidden (only after overlay mount succeeds). */
|
|
535
|
+
this.overlayMounted = false;
|
|
536
|
+
this.addedRootClass = false;
|
|
537
|
+
this.addedContainingBlockClass = false;
|
|
538
|
+
this.retainedDocumentNativeHide = false;
|
|
539
|
+
this.retainedStyles = false;
|
|
540
|
+
this.unbindHostInteraction = null;
|
|
541
|
+
}
|
|
542
|
+
attach() {
|
|
543
|
+
if (this.overlayMounted) {
|
|
544
|
+
return true;
|
|
545
|
+
}
|
|
546
|
+
const element = this.hostEl;
|
|
547
|
+
if (element.hasAttribute(HOST_INIT_ATTR)) {
|
|
548
|
+
return false;
|
|
549
|
+
}
|
|
550
|
+
injectOverlayScrollbarStyles(this.document);
|
|
551
|
+
this.retainedStyles = true;
|
|
552
|
+
element.setAttribute(HOST_INIT_ATTR, '');
|
|
553
|
+
const scroller = this.getScrollMetricsElement();
|
|
554
|
+
this.applyConfigDesignTokens(element);
|
|
555
|
+
this.mountCustomScrollbar(element);
|
|
556
|
+
this.applyConfigDesignTokens(this.rootEl);
|
|
557
|
+
this.overlayMounted = true;
|
|
558
|
+
element.classList.add('ax-cdk-overlay-scrollbar');
|
|
559
|
+
const interactionRoot = () => this.rootEl ?? element;
|
|
560
|
+
const view = this.document.defaultView;
|
|
561
|
+
const onScroll = () => {
|
|
562
|
+
this.markScrolling();
|
|
563
|
+
this.syncThumbPosition(true);
|
|
564
|
+
this.bumpVisibility();
|
|
565
|
+
};
|
|
566
|
+
const onScrollEnd = () => {
|
|
567
|
+
this.endScrolling();
|
|
568
|
+
this.scheduleHide();
|
|
569
|
+
this.syncEngagedAfterScroll();
|
|
570
|
+
};
|
|
571
|
+
scroller.addEventListener('scroll', onScroll, { passive: true });
|
|
572
|
+
scroller.addEventListener('scrollend', onScrollEnd);
|
|
573
|
+
if ((this.isDocumentScroller(element) || this.isDocumentScrollAttachment()) && view) {
|
|
574
|
+
view.addEventListener('scroll', onScroll, { passive: true });
|
|
575
|
+
view.addEventListener('scrollend', onScrollEnd);
|
|
576
|
+
}
|
|
577
|
+
const root = interactionRoot();
|
|
578
|
+
const onPointerActivity = () => this.bumpVisibility();
|
|
579
|
+
const onPointerLeave = (event) => {
|
|
580
|
+
const related = event.relatedTarget;
|
|
581
|
+
if (related instanceof Node && (root.contains(related) || element.contains(related))) {
|
|
408
582
|
return;
|
|
409
583
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
effect(() => {
|
|
413
|
-
if (!isPlatformBrowser(this.platformId)) {
|
|
414
|
-
return;
|
|
584
|
+
if (this.thumbDragPointerId === null) {
|
|
585
|
+
this.setScrollbarEngaged(false);
|
|
415
586
|
}
|
|
416
|
-
this.
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
587
|
+
this.scheduleHide();
|
|
588
|
+
};
|
|
589
|
+
root.addEventListener('pointerenter', onPointerActivity);
|
|
590
|
+
root.addEventListener('pointermove', onPointerActivity);
|
|
591
|
+
root.addEventListener('pointerleave', onPointerLeave);
|
|
592
|
+
if (root.matches(':hover')) {
|
|
593
|
+
onPointerActivity();
|
|
594
|
+
}
|
|
595
|
+
this.bindRailInteraction(scroller);
|
|
596
|
+
const onResize = () => {
|
|
597
|
+
if (this.isScrolling) {
|
|
598
|
+
this.pendingRemeasure = true;
|
|
421
599
|
return;
|
|
422
600
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
601
|
+
this.queueOverflowRemeasure();
|
|
602
|
+
};
|
|
603
|
+
this.resizeObserver = new ResizeObserver(onResize);
|
|
604
|
+
this.resizeObserver.observe(element);
|
|
605
|
+
if (this.isDocumentScroller(element) || this.isDocumentScrollAttachment()) {
|
|
606
|
+
this.resizeObserver.observe(this.document.body);
|
|
607
|
+
view?.addEventListener('resize', onResize);
|
|
608
|
+
}
|
|
609
|
+
this.observeOverflowContent(element);
|
|
610
|
+
this.observeHostDesignTokenChanges(this.tokenStyleSource());
|
|
611
|
+
this.queueDesignTokenSync();
|
|
612
|
+
this.remeasureCustomThumb();
|
|
613
|
+
OVERLAY_SCROLLBAR_RUNTIMES.set(element, this);
|
|
614
|
+
this.unbindHostInteraction = () => {
|
|
615
|
+
this.clearHideTimer();
|
|
616
|
+
this.clearScrollIdleTimer();
|
|
617
|
+
this.pointerOverRail = false;
|
|
618
|
+
this.isScrolling = false;
|
|
619
|
+
this.pendingRemeasure = false;
|
|
620
|
+
this.clearTrackPressed();
|
|
621
|
+
this.unbindRailInteraction?.();
|
|
622
|
+
this.unbindRailInteraction = null;
|
|
623
|
+
if (this.thumbEl && this.thumbDragPointerId !== null) {
|
|
624
|
+
try {
|
|
625
|
+
this.thumbEl.releasePointerCapture(this.thumbDragPointerId);
|
|
440
626
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
this.
|
|
450
|
-
this.
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
this.
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
627
|
+
catch {
|
|
628
|
+
/* already released */
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
this.thumbDragPointerId = null;
|
|
632
|
+
this.resizeObserver?.disconnect();
|
|
633
|
+
this.resizeObserver = null;
|
|
634
|
+
this.contentMutationObserver?.disconnect();
|
|
635
|
+
this.contentMutationObserver = null;
|
|
636
|
+
if (this.overflowRemeasureFrame !== null) {
|
|
637
|
+
cancelAnimationFrame(this.overflowRemeasureFrame);
|
|
638
|
+
this.overflowRemeasureFrame = null;
|
|
639
|
+
}
|
|
640
|
+
if ((this.isDocumentScroller(element) || this.isDocumentScrollAttachment()) && view) {
|
|
641
|
+
view.removeEventListener('resize', onResize);
|
|
642
|
+
}
|
|
643
|
+
this.designTokenMutationObserver?.disconnect();
|
|
644
|
+
this.designTokenMutationObserver = null;
|
|
645
|
+
if (this.designTokenSyncFrame !== null) {
|
|
646
|
+
cancelAnimationFrame(this.designTokenSyncFrame);
|
|
647
|
+
this.designTokenSyncFrame = null;
|
|
648
|
+
}
|
|
649
|
+
scroller.removeEventListener('scroll', onScroll);
|
|
650
|
+
scroller.removeEventListener('scrollend', onScrollEnd);
|
|
651
|
+
if ((this.isDocumentScroller(element) || this.isDocumentScrollAttachment()) && view) {
|
|
652
|
+
view.removeEventListener('scroll', onScroll);
|
|
653
|
+
view.removeEventListener('scrollend', onScrollEnd);
|
|
654
|
+
}
|
|
655
|
+
root.removeEventListener('pointerenter', onPointerActivity);
|
|
656
|
+
root.removeEventListener('pointermove', onPointerActivity);
|
|
657
|
+
root.removeEventListener('pointerleave', onPointerLeave);
|
|
658
|
+
};
|
|
659
|
+
return true;
|
|
660
|
+
}
|
|
661
|
+
isAttached() {
|
|
662
|
+
return this.overlayMounted;
|
|
663
|
+
}
|
|
664
|
+
updateOptions(patch) {
|
|
665
|
+
this.options = { ...this.options, ...patch };
|
|
666
|
+
if (!this.overlayMounted) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
this.remeasureCustomThumb();
|
|
670
|
+
}
|
|
671
|
+
detach() {
|
|
672
|
+
if (!this.overlayMounted && !this.unbindHostInteraction) {
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
const element = this.hostEl;
|
|
676
|
+
this.clearNavRepeat();
|
|
677
|
+
this.unbindHostInteraction?.();
|
|
678
|
+
this.unbindHostInteraction = null;
|
|
679
|
+
this.unmountCustomScrollbar(element);
|
|
680
|
+
OVERLAY_SCROLLBAR_RUNTIMES.delete(element);
|
|
681
|
+
element.removeAttribute(HOST_INIT_ATTR);
|
|
682
|
+
element.classList.remove('ax-cdk-overlay-scrollbar');
|
|
683
|
+
this.overlayMounted = false;
|
|
684
|
+
if (this.retainedStyles) {
|
|
685
|
+
releaseOverlayScrollbarStyles(this.document);
|
|
686
|
+
this.retainedStyles = false;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
/** Content can grow without the host box changing (side menu items). Remeasure overflow when that happens. */
|
|
690
|
+
observeOverflowContent(element) {
|
|
691
|
+
this.contentMutationObserver?.disconnect();
|
|
692
|
+
this.contentMutationObserver = new MutationObserver((records) => {
|
|
693
|
+
for (const record of records) {
|
|
694
|
+
if (record.type === 'characterData') {
|
|
695
|
+
this.queueOverflowRemeasure();
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
for (const node of record.addedNodes) {
|
|
699
|
+
if (this.isOverlayChromeNode(node)) {
|
|
700
|
+
continue;
|
|
463
701
|
}
|
|
464
|
-
|
|
465
|
-
|
|
702
|
+
if (node instanceof Element && node.parentElement === element) {
|
|
703
|
+
this.resizeObserver?.observe(node);
|
|
466
704
|
}
|
|
705
|
+
this.queueOverflowRemeasure();
|
|
706
|
+
return;
|
|
467
707
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
cancelAnimationFrame(this.designTokenSyncFrame);
|
|
475
|
-
this.designTokenSyncFrame = null;
|
|
708
|
+
for (const node of record.removedNodes) {
|
|
709
|
+
if (this.isOverlayChromeNode(node)) {
|
|
710
|
+
continue;
|
|
711
|
+
}
|
|
712
|
+
this.queueOverflowRemeasure();
|
|
713
|
+
return;
|
|
476
714
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
this.contentMutationObserver.observe(element, {
|
|
718
|
+
childList: true,
|
|
719
|
+
subtree: true,
|
|
720
|
+
characterData: true,
|
|
721
|
+
});
|
|
722
|
+
for (const child of Array.from(element.children)) {
|
|
723
|
+
if (!this.isOverlayChromeNode(child)) {
|
|
724
|
+
this.resizeObserver?.observe(child);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
isOverlayChromeNode(node) {
|
|
729
|
+
return node instanceof Element && !!node.closest(`.${RAIL_CLASS}`);
|
|
730
|
+
}
|
|
731
|
+
queueOverflowRemeasure() {
|
|
732
|
+
if (this.overflowRemeasureFrame !== null) {
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
this.overflowRemeasureFrame = requestAnimationFrame(() => {
|
|
736
|
+
this.overflowRemeasureFrame = null;
|
|
737
|
+
if (!this.overlayMounted) {
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
if (this.isScrolling) {
|
|
741
|
+
this.pendingRemeasure = true;
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
this.remeasureCustomThumb();
|
|
484
745
|
});
|
|
485
746
|
}
|
|
486
747
|
/** Host and rail are siblings under the root; mirror CSS variables when the host style/class changes. */
|
|
@@ -489,80 +750,138 @@ class AXOverlayScrollbarDirective {
|
|
|
489
750
|
this.designTokenMutationObserver = new MutationObserver(() => this.queueDesignTokenSync());
|
|
490
751
|
this.designTokenMutationObserver.observe(host, {
|
|
491
752
|
attributes: true,
|
|
492
|
-
attributeFilter: ['style'
|
|
753
|
+
attributeFilter: ['style'],
|
|
493
754
|
});
|
|
494
755
|
}
|
|
495
756
|
queueDesignTokenSync() {
|
|
496
|
-
if (!isPlatformBrowser(this.platformId)) {
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
757
|
if (this.designTokenSyncFrame !== null) {
|
|
500
758
|
cancelAnimationFrame(this.designTokenSyncFrame);
|
|
501
759
|
}
|
|
502
760
|
this.designTokenSyncFrame = requestAnimationFrame(() => {
|
|
503
761
|
this.designTokenSyncFrame = null;
|
|
504
|
-
syncOverlayScrollbarDesignTokens(this.
|
|
762
|
+
syncOverlayScrollbarDesignTokens(this.tokenStyleSource(), this.rootEl);
|
|
505
763
|
this.remeasureCustomThumb();
|
|
506
764
|
});
|
|
507
765
|
}
|
|
508
|
-
|
|
766
|
+
isDocumentScroller(element) {
|
|
767
|
+
const doc = element.ownerDocument;
|
|
768
|
+
return element === doc.documentElement || element === doc.body;
|
|
769
|
+
}
|
|
770
|
+
/** Document-level attachment (invisible anchor); not the same as host `html`/`body`. */
|
|
771
|
+
isDocumentScrollAttachment() {
|
|
772
|
+
return this.options.documentScroll === true;
|
|
773
|
+
}
|
|
774
|
+
tokenStyleSource() {
|
|
775
|
+
return this.isDocumentScrollAttachment() ? this.document.documentElement : this.hostEl;
|
|
776
|
+
}
|
|
777
|
+
applyConfigDesignTokens(target) {
|
|
778
|
+
if (!target) {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
applyOverlayScrollbarDesignTokens(target, this.config.designTokens);
|
|
782
|
+
}
|
|
783
|
+
/** html/body scroll through `scrollingElement`; nested hosts scroll themselves. */
|
|
784
|
+
getScrollMetricsElement() {
|
|
785
|
+
const host = this.hostEl;
|
|
786
|
+
if (this.isDocumentScrollAttachment()) {
|
|
787
|
+
return host.ownerDocument.scrollingElement ?? host.ownerDocument.documentElement;
|
|
788
|
+
}
|
|
789
|
+
if (!this.isDocumentScroller(host)) {
|
|
790
|
+
return host;
|
|
791
|
+
}
|
|
792
|
+
return host.ownerDocument.scrollingElement ?? host;
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Positions the rail on the scroll host itself. Never wraps or reparents the scroller.
|
|
796
|
+
*/
|
|
509
797
|
ensureScrollRoot(scroller) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
this.
|
|
513
|
-
return
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
return root;
|
|
798
|
+
if (this.isDocumentScrollAttachment() || this.isDocumentScroller(scroller)) {
|
|
799
|
+
this.rootEl = this.document.body;
|
|
800
|
+
this.addedRootClass = false;
|
|
801
|
+
return this.document.body;
|
|
802
|
+
}
|
|
803
|
+
this.addedRootClass = !scroller.classList.contains(ROOT_CLASS);
|
|
804
|
+
scroller.classList.add(ROOT_CLASS);
|
|
805
|
+
this.ensureContainingBlock(scroller);
|
|
806
|
+
this.rootEl = scroller;
|
|
807
|
+
return scroller;
|
|
521
808
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
const
|
|
525
|
-
if (
|
|
526
|
-
this.
|
|
527
|
-
this.ensureRailStructure(existingRail);
|
|
528
|
-
this.bindRailInteraction(element);
|
|
809
|
+
/** Absolute rails need a containing block, but must not override sticky/fixed/absolute hosts. */
|
|
810
|
+
ensureContainingBlock(scroller) {
|
|
811
|
+
const position = getComputedStyle(scroller).position;
|
|
812
|
+
if (position !== 'static') {
|
|
813
|
+
this.addedContainingBlockClass = false;
|
|
529
814
|
return;
|
|
530
815
|
}
|
|
816
|
+
this.addedContainingBlockClass = !scroller.classList.contains(CONTAINING_BLOCK_CLASS);
|
|
817
|
+
scroller.classList.add(CONTAINING_BLOCK_CLASS);
|
|
818
|
+
}
|
|
819
|
+
mountCustomScrollbar(element) {
|
|
820
|
+
if (this.isDocumentScrollAttachment()) {
|
|
821
|
+
retainOverlayDocumentNativeHide(this.document);
|
|
822
|
+
this.retainedDocumentNativeHide = true;
|
|
823
|
+
}
|
|
824
|
+
const root = this.ensureScrollRoot(element);
|
|
825
|
+
const scroller = this.getScrollMetricsElement();
|
|
826
|
+
const kids = Array.from(root.children);
|
|
827
|
+
const existingVertical = kids.find((child) => child.classList.contains(RAIL_CLASS) && !child.classList.contains(RAIL_HORIZONTAL_CLASS));
|
|
828
|
+
const existingHorizontal = kids.find((child) => child.classList.contains(RAIL_HORIZONTAL_CLASS));
|
|
829
|
+
this.railEl = existingVertical ?? this.createRail(root, 'y', element);
|
|
830
|
+
this.xRailEl = existingHorizontal ?? this.createRail(root, 'x', element);
|
|
831
|
+
this.ensureRailStructure(this.railEl, 'y');
|
|
832
|
+
this.ensureRailStructure(this.xRailEl, 'x');
|
|
833
|
+
this.bindRailInteraction(scroller);
|
|
834
|
+
}
|
|
835
|
+
createRail(root, axis, element) {
|
|
531
836
|
const rail = this.document.createElement('div');
|
|
532
|
-
rail.className = RAIL_CLASS
|
|
837
|
+
rail.className = axis === 'x' ? `${RAIL_CLASS} ${RAIL_HORIZONTAL_CLASS}` : `${RAIL_CLASS} ${RAIL_VERTICAL_CLASS}`;
|
|
838
|
+
if (this.isDocumentScroller(element) || this.isDocumentScrollAttachment()) {
|
|
839
|
+
rail.classList.add(DOCUMENT_RAIL_CLASS);
|
|
840
|
+
}
|
|
533
841
|
rail.setAttribute('aria-hidden', 'true');
|
|
534
|
-
|
|
842
|
+
rail.setAttribute('data-ax-overlay-axis', axis);
|
|
535
843
|
root.appendChild(rail);
|
|
536
|
-
|
|
537
|
-
this.bindRailInteraction(element);
|
|
844
|
+
return rail;
|
|
538
845
|
}
|
|
539
|
-
ensureRailStructure(rail) {
|
|
846
|
+
ensureRailStructure(rail, axis) {
|
|
540
847
|
let thumb = rail.querySelector(`.${THUMB_CLASS}`);
|
|
541
848
|
if (!thumb) {
|
|
542
849
|
thumb = this.document.createElement('div');
|
|
543
850
|
thumb.className = THUMB_CLASS;
|
|
544
|
-
thumb.addEventListener('pointerdown', (event) => this.onThumbPointerDown(event));
|
|
851
|
+
thumb.addEventListener('pointerdown', (event) => this.onThumbPointerDown(event, axis));
|
|
545
852
|
}
|
|
546
853
|
let track = rail.querySelector(`.${TRACK_CLASS}`);
|
|
547
854
|
if (!track) {
|
|
548
|
-
const navUp = this.createNavButton('up');
|
|
549
|
-
const navDown = this.createNavButton('down');
|
|
550
855
|
track = this.document.createElement('div');
|
|
551
856
|
track.className = TRACK_CLASS;
|
|
552
|
-
|
|
857
|
+
if (axis === 'y') {
|
|
858
|
+
const navUp = this.createNavButton('up');
|
|
859
|
+
const navDown = this.createNavButton('down');
|
|
860
|
+
rail.replaceChildren(navUp, track, navDown);
|
|
861
|
+
this.navUpEl = navUp;
|
|
862
|
+
this.navDownEl = navDown;
|
|
863
|
+
}
|
|
864
|
+
else {
|
|
865
|
+
const navStart = this.createNavButton('start');
|
|
866
|
+
const navEnd = this.createNavButton('end');
|
|
867
|
+
rail.replaceChildren(navStart, track, navEnd);
|
|
868
|
+
this.navStartEl = navStart;
|
|
869
|
+
this.navEndEl = navEnd;
|
|
870
|
+
}
|
|
553
871
|
track.appendChild(thumb);
|
|
554
|
-
this.navUpEl = navUp;
|
|
555
|
-
this.navDownEl = navDown;
|
|
556
872
|
}
|
|
557
873
|
else if (!track.contains(thumb)) {
|
|
558
874
|
track.appendChild(thumb);
|
|
559
|
-
this.navUpEl = rail.querySelector(`.${NAV_BTN_CLASS}--up`);
|
|
560
|
-
this.navDownEl = rail.querySelector(`.${NAV_BTN_CLASS}--down`);
|
|
561
875
|
}
|
|
562
|
-
|
|
563
|
-
this.
|
|
564
|
-
this.
|
|
876
|
+
if (axis === 'x') {
|
|
877
|
+
this.navStartEl = rail.querySelector(`.${NAV_BTN_CLASS}--start`);
|
|
878
|
+
this.navEndEl = rail.querySelector(`.${NAV_BTN_CLASS}--end`);
|
|
879
|
+
this.xTrackEl = track;
|
|
880
|
+
this.xThumbEl = thumb;
|
|
881
|
+
return;
|
|
565
882
|
}
|
|
883
|
+
this.navUpEl = rail.querySelector(`.${NAV_BTN_CLASS}--up`);
|
|
884
|
+
this.navDownEl = rail.querySelector(`.${NAV_BTN_CLASS}--down`);
|
|
566
885
|
this.trackEl = track;
|
|
567
886
|
this.thumbEl = thumb;
|
|
568
887
|
}
|
|
@@ -570,7 +889,13 @@ class AXOverlayScrollbarDirective {
|
|
|
570
889
|
const button = this.document.createElement('button');
|
|
571
890
|
button.type = 'button';
|
|
572
891
|
button.className = `${NAV_BTN_CLASS} ${NAV_BTN_CLASS}--${direction}`;
|
|
573
|
-
|
|
892
|
+
const labels = {
|
|
893
|
+
up: 'Scroll up',
|
|
894
|
+
down: 'Scroll down',
|
|
895
|
+
start: 'Scroll left',
|
|
896
|
+
end: 'Scroll right',
|
|
897
|
+
};
|
|
898
|
+
button.setAttribute('aria-label', labels[direction]);
|
|
574
899
|
const arrow = this.document.createElement('span');
|
|
575
900
|
arrow.className = `${NAV_ARROW_CLASS} ${NAV_ARROW_CLASS}--${direction}`;
|
|
576
901
|
arrow.setAttribute('aria-hidden', 'true');
|
|
@@ -578,23 +903,58 @@ class AXOverlayScrollbarDirective {
|
|
|
578
903
|
return button;
|
|
579
904
|
}
|
|
580
905
|
resolveNavScrollStepPx() {
|
|
581
|
-
const step = this.navScrollStep
|
|
906
|
+
const step = this.options.navScrollStep;
|
|
582
907
|
if (Number.isFinite(step) && step > 0) {
|
|
583
908
|
return Math.round(step);
|
|
584
909
|
}
|
|
585
910
|
return DEFAULT_NAV_SCROLL_STEP_PX;
|
|
586
911
|
}
|
|
587
|
-
scrollByNavStep(scroller, direction) {
|
|
588
|
-
|
|
589
|
-
|
|
912
|
+
scrollByNavStep(scroller, direction, axis = 'y') {
|
|
913
|
+
const step = direction * this.resolveNavScrollStepPx();
|
|
914
|
+
if (axis === 'x') {
|
|
915
|
+
scroller.scrollLeft += step;
|
|
916
|
+
}
|
|
917
|
+
else {
|
|
918
|
+
scroller.scrollTop += step;
|
|
919
|
+
}
|
|
920
|
+
this.syncThumbPosition(true);
|
|
590
921
|
this.bumpVisibility();
|
|
591
922
|
}
|
|
923
|
+
startNavRepeat(scroller, direction, axis) {
|
|
924
|
+
this.clearNavRepeat();
|
|
925
|
+
this.navRepeatDelayTimer = setTimeout(() => {
|
|
926
|
+
this.navRepeatDelayTimer = null;
|
|
927
|
+
this.navRepeatTimer = setInterval(() => {
|
|
928
|
+
this.scrollByNavStep(scroller, direction, axis);
|
|
929
|
+
}, NAV_REPEAT_INTERVAL_MS);
|
|
930
|
+
}, NAV_REPEAT_DELAY_MS);
|
|
931
|
+
}
|
|
932
|
+
clearNavRepeat() {
|
|
933
|
+
if (this.navRepeatDelayTimer !== null) {
|
|
934
|
+
clearTimeout(this.navRepeatDelayTimer);
|
|
935
|
+
this.navRepeatDelayTimer = null;
|
|
936
|
+
}
|
|
937
|
+
if (this.navRepeatTimer !== null) {
|
|
938
|
+
clearInterval(this.navRepeatTimer);
|
|
939
|
+
this.navRepeatTimer = null;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
592
942
|
bindRailInteraction(scroller) {
|
|
593
|
-
|
|
943
|
+
this.unbindRailInteraction?.();
|
|
944
|
+
const unbindY = this.bindAxisRailInteraction(scroller, 'y');
|
|
945
|
+
const unbindX = this.bindAxisRailInteraction(scroller, 'x');
|
|
946
|
+
this.unbindRailInteraction = () => {
|
|
947
|
+
unbindY();
|
|
948
|
+
unbindX();
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
bindAxisRailInteraction(scroller, axis) {
|
|
952
|
+
const rail = axis === 'x' ? this.xRailEl : this.railEl;
|
|
953
|
+
const thumb = axis === 'x' ? this.xThumbEl : this.thumbEl;
|
|
954
|
+
const track = axis === 'x' ? this.xTrackEl : this.trackEl;
|
|
594
955
|
if (!rail) {
|
|
595
|
-
return;
|
|
956
|
+
return () => undefined;
|
|
596
957
|
}
|
|
597
|
-
this.unbindRailInteraction?.();
|
|
598
958
|
const onRailPointerEnter = () => {
|
|
599
959
|
this.pointerOverRail = true;
|
|
600
960
|
this.showScrollbar();
|
|
@@ -609,120 +969,207 @@ class AXOverlayScrollbarDirective {
|
|
|
609
969
|
const onRailWheel = (event) => {
|
|
610
970
|
event.preventDefault();
|
|
611
971
|
event.stopPropagation();
|
|
612
|
-
|
|
972
|
+
if (axis === 'x') {
|
|
973
|
+
scroller.scrollLeft += event.deltaX || event.deltaY;
|
|
974
|
+
}
|
|
975
|
+
else {
|
|
976
|
+
scroller.scrollTop += event.deltaY;
|
|
977
|
+
}
|
|
613
978
|
this.bumpVisibility();
|
|
614
979
|
};
|
|
615
980
|
const onRailPointerDown = (event) => {
|
|
616
|
-
const thumb = this.thumbEl;
|
|
617
981
|
const target = event.target;
|
|
618
982
|
if (thumb && (event.target === thumb || thumb.contains(target))) {
|
|
619
983
|
return;
|
|
620
984
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
event.target === this.navUpEl ||
|
|
624
|
-
event.target === this.navDownEl) {
|
|
985
|
+
const navButtons = axis === 'x' ? [this.navStartEl, this.navEndEl] : [this.navUpEl, this.navDownEl];
|
|
986
|
+
if (navButtons.some((button) => button && (event.target === button || button.contains(target)))) {
|
|
625
987
|
return;
|
|
626
988
|
}
|
|
627
|
-
const track = this.trackEl;
|
|
628
989
|
if (!track || (event.target !== track && !track.contains(target))) {
|
|
629
990
|
return;
|
|
630
991
|
}
|
|
631
|
-
if (this.isPointerOverThumbVisual(event.clientX, event.clientY)) {
|
|
992
|
+
if (this.isPointerOverThumbVisual(event.clientX, event.clientY, axis)) {
|
|
632
993
|
return;
|
|
633
994
|
}
|
|
634
995
|
event.preventDefault();
|
|
635
996
|
this.beginTrackPressed();
|
|
636
|
-
this.jumpScrollToTrackPointer(event, scroller);
|
|
997
|
+
this.jumpScrollToTrackPointer(event, scroller, axis);
|
|
637
998
|
};
|
|
638
999
|
const bindNavButton = (button, direction) => {
|
|
639
1000
|
if (!button) {
|
|
640
1001
|
return () => undefined;
|
|
641
1002
|
}
|
|
642
|
-
const
|
|
1003
|
+
const stopRepeat = () => {
|
|
1004
|
+
this.clearNavRepeat();
|
|
643
1005
|
button.classList.remove(NAV_BTN_PRESSED_CLASS);
|
|
644
1006
|
};
|
|
645
1007
|
const onNavPointerDown = (event) => {
|
|
646
1008
|
event.preventDefault();
|
|
647
1009
|
event.stopPropagation();
|
|
1010
|
+
button.setPointerCapture(event.pointerId);
|
|
648
1011
|
button.classList.add(NAV_BTN_PRESSED_CLASS);
|
|
649
|
-
this.
|
|
650
|
-
this.
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
button.classList.remove(NAV_BTN_PRESSED_CLASS);
|
|
1012
|
+
this.showScrollbar();
|
|
1013
|
+
this.clearHideTimer();
|
|
1014
|
+
this.scrollByNavStep(scroller, direction, axis);
|
|
1015
|
+
this.startNavRepeat(scroller, direction, axis);
|
|
654
1016
|
};
|
|
655
|
-
button.addEventListener('pointerleave', onNavPointerLeave);
|
|
656
1017
|
button.addEventListener('pointerdown', onNavPointerDown);
|
|
657
|
-
button.addEventListener('pointerup',
|
|
658
|
-
button.addEventListener('pointercancel',
|
|
1018
|
+
button.addEventListener('pointerup', stopRepeat);
|
|
1019
|
+
button.addEventListener('pointercancel', stopRepeat);
|
|
1020
|
+
button.addEventListener('lostpointercapture', stopRepeat);
|
|
659
1021
|
return () => {
|
|
660
|
-
|
|
1022
|
+
this.clearNavRepeat();
|
|
661
1023
|
button.removeEventListener('pointerdown', onNavPointerDown);
|
|
662
|
-
button.removeEventListener('pointerup',
|
|
663
|
-
button.removeEventListener('pointercancel',
|
|
1024
|
+
button.removeEventListener('pointerup', stopRepeat);
|
|
1025
|
+
button.removeEventListener('pointercancel', stopRepeat);
|
|
1026
|
+
button.removeEventListener('lostpointercapture', stopRepeat);
|
|
664
1027
|
button.classList.remove(NAV_BTN_PRESSED_CLASS);
|
|
665
1028
|
};
|
|
666
1029
|
};
|
|
667
|
-
const
|
|
668
|
-
const
|
|
1030
|
+
const unbindNavStart = bindNavButton(axis === 'x' ? this.navStartEl : this.navUpEl, -1);
|
|
1031
|
+
const unbindNavEnd = bindNavButton(axis === 'x' ? this.navEndEl : this.navDownEl, 1);
|
|
669
1032
|
rail.addEventListener('pointerenter', onRailPointerEnter);
|
|
670
1033
|
rail.addEventListener('pointerleave', onRailPointerLeave);
|
|
671
1034
|
rail.addEventListener('wheel', onRailWheel, { passive: false });
|
|
672
1035
|
rail.addEventListener('pointerdown', onRailPointerDown);
|
|
673
|
-
|
|
1036
|
+
return () => {
|
|
674
1037
|
rail.removeEventListener('pointerenter', onRailPointerEnter);
|
|
675
1038
|
rail.removeEventListener('pointerleave', onRailPointerLeave);
|
|
676
1039
|
this.clearTrackPressed();
|
|
677
1040
|
rail.removeEventListener('wheel', onRailWheel);
|
|
678
1041
|
rail.removeEventListener('pointerdown', onRailPointerDown);
|
|
679
|
-
|
|
680
|
-
|
|
1042
|
+
unbindNavStart();
|
|
1043
|
+
unbindNavEnd();
|
|
681
1044
|
};
|
|
682
1045
|
}
|
|
683
|
-
unmountCustomScrollbar(
|
|
1046
|
+
unmountCustomScrollbar(_scroller) {
|
|
1047
|
+
if (this.retainedDocumentNativeHide) {
|
|
1048
|
+
releaseOverlayDocumentNativeHide(this.document);
|
|
1049
|
+
this.retainedDocumentNativeHide = false;
|
|
1050
|
+
}
|
|
684
1051
|
this.railEl?.remove();
|
|
685
1052
|
this.railEl = null;
|
|
686
1053
|
this.trackEl = null;
|
|
687
1054
|
this.navUpEl = null;
|
|
688
1055
|
this.navDownEl = null;
|
|
1056
|
+
this.navStartEl = null;
|
|
1057
|
+
this.navEndEl = null;
|
|
689
1058
|
this.thumbEl = null;
|
|
690
1059
|
this.thumbLayout = null;
|
|
1060
|
+
this.xRailEl?.remove();
|
|
1061
|
+
this.xRailEl = null;
|
|
1062
|
+
this.xTrackEl = null;
|
|
1063
|
+
this.xThumbEl = null;
|
|
1064
|
+
this.xThumbLayout = null;
|
|
691
1065
|
const root = this.rootEl;
|
|
692
|
-
|
|
693
|
-
|
|
1066
|
+
this.rootEl = null;
|
|
1067
|
+
if (this.addedRootClass && root && root !== this.document.body) {
|
|
1068
|
+
root.classList.remove(ROOT_CLASS);
|
|
1069
|
+
}
|
|
1070
|
+
this.addedRootClass = false;
|
|
1071
|
+
if (this.addedContainingBlockClass && root && root !== this.document.body) {
|
|
1072
|
+
root.classList.remove(CONTAINING_BLOCK_CLASS);
|
|
1073
|
+
}
|
|
1074
|
+
this.addedContainingBlockClass = false;
|
|
1075
|
+
}
|
|
1076
|
+
readViewportHeight(element) {
|
|
1077
|
+
if (this.isDocumentScroller(this.hostEl) || this.isDocumentScrollAttachment()) {
|
|
1078
|
+
return this.document.defaultView?.innerHeight ?? element.clientHeight;
|
|
1079
|
+
}
|
|
1080
|
+
return element.clientHeight;
|
|
1081
|
+
}
|
|
1082
|
+
readViewportWidth(element) {
|
|
1083
|
+
if (this.isDocumentScroller(this.hostEl) || this.isDocumentScrollAttachment()) {
|
|
1084
|
+
return this.document.defaultView?.innerWidth ?? element.clientWidth;
|
|
1085
|
+
}
|
|
1086
|
+
return element.clientWidth;
|
|
1087
|
+
}
|
|
1088
|
+
pinRailsToViewport(scrollLeft, scrollTop) {
|
|
1089
|
+
if (this.isDocumentScroller(this.hostEl) || this.isDocumentScrollAttachment()) {
|
|
694
1090
|
return;
|
|
695
1091
|
}
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
1092
|
+
const yMax = this.thumbLayout?.maxScroll;
|
|
1093
|
+
const xMax = this.xThumbLayout?.maxScroll;
|
|
1094
|
+
const y = yMax == null ? Math.max(0, scrollTop) : Math.min(Math.max(0, scrollTop), yMax);
|
|
1095
|
+
const x = xMax == null ? scrollLeft : Math.max(Math.min(scrollLeft, Math.abs(xMax)), -Math.abs(xMax));
|
|
1096
|
+
const transform = `translate3d(${x}px, ${y}px, 0)`;
|
|
1097
|
+
if (this.railEl) {
|
|
1098
|
+
this.railEl.style.top = '0';
|
|
1099
|
+
this.railEl.style.transform = transform;
|
|
1100
|
+
}
|
|
1101
|
+
if (this.xRailEl) {
|
|
1102
|
+
this.xRailEl.style.bottom = '0';
|
|
1103
|
+
this.xRailEl.style.top = 'auto';
|
|
1104
|
+
this.xRailEl.style.transform = transform;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
layoutMetricsChanged(element) {
|
|
1108
|
+
const yLayout = this.thumbLayout;
|
|
1109
|
+
const xLayout = this.xThumbLayout;
|
|
1110
|
+
const yChanged = !yLayout ||
|
|
1111
|
+
Math.abs(yLayout.clientHeight - this.readViewportHeight(element)) > 1 ||
|
|
1112
|
+
Math.abs(yLayout.scrollHeight - element.scrollHeight) > 1;
|
|
1113
|
+
const xChanged = !xLayout ||
|
|
1114
|
+
Math.abs(xLayout.clientWidth - this.readViewportWidth(element)) > 1 ||
|
|
1115
|
+
Math.abs(xLayout.scrollWidth - element.scrollWidth) > 1;
|
|
1116
|
+
return yChanged || xChanged;
|
|
1117
|
+
}
|
|
1118
|
+
markScrolling() {
|
|
1119
|
+
this.isScrolling = true;
|
|
1120
|
+
this.clearScrollIdleTimer();
|
|
1121
|
+
this.scrollIdleTimer = setTimeout(() => this.endScrolling(), 80);
|
|
1122
|
+
}
|
|
1123
|
+
endScrolling() {
|
|
1124
|
+
this.clearScrollIdleTimer();
|
|
1125
|
+
this.isScrolling = false;
|
|
1126
|
+
if (!this.pendingRemeasure) {
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
this.pendingRemeasure = false;
|
|
1130
|
+
this.remeasureCustomThumb();
|
|
1131
|
+
}
|
|
1132
|
+
clearScrollIdleTimer() {
|
|
1133
|
+
if (this.scrollIdleTimer !== null) {
|
|
1134
|
+
clearTimeout(this.scrollIdleTimer);
|
|
1135
|
+
this.scrollIdleTimer = null;
|
|
700
1136
|
}
|
|
701
|
-
this.rootEl = null;
|
|
702
1137
|
}
|
|
703
1138
|
remeasureCustomThumb() {
|
|
704
|
-
const element = this.
|
|
1139
|
+
const element = this.getScrollMetricsElement();
|
|
1140
|
+
syncOverlayScrollbarDesignTokens(this.tokenStyleSource(), this.rootEl);
|
|
1141
|
+
this.remeasureVerticalThumb(element);
|
|
1142
|
+
this.remeasureHorizontalThumb(element);
|
|
1143
|
+
}
|
|
1144
|
+
remeasureVerticalThumb(element) {
|
|
705
1145
|
const rail = this.railEl;
|
|
706
1146
|
const thumb = this.thumbEl;
|
|
707
1147
|
if (!rail || !thumb) {
|
|
708
1148
|
return;
|
|
709
1149
|
}
|
|
710
|
-
|
|
711
|
-
const
|
|
1150
|
+
const clientHeight = this.readViewportHeight(element);
|
|
1151
|
+
const scrollHeight = element.scrollHeight;
|
|
1152
|
+
const isScrollable = scrollHeight > clientHeight + 1;
|
|
1153
|
+
const navigationEnabled = this.options.navigationButtons === true && isScrollable;
|
|
712
1154
|
rail.style.height = `${clientHeight}px`;
|
|
713
|
-
|
|
714
|
-
const navigationEnabled = this.navigationButtons() === true;
|
|
1155
|
+
this.pinRailsToViewport(element.scrollLeft, element.scrollTop);
|
|
715
1156
|
rail.classList.toggle(RAIL_WITH_NAV_CLASS, navigationEnabled);
|
|
1157
|
+
const widthPx = readRailWidthPx(rail);
|
|
716
1158
|
const track = this.trackEl;
|
|
717
1159
|
let trackViewportHeight = track?.clientHeight ?? 0;
|
|
718
1160
|
if (trackViewportHeight <= 0) {
|
|
719
1161
|
trackViewportHeight = navigationEnabled ? Math.max(0, clientHeight - 2 * widthPx) : clientHeight;
|
|
720
1162
|
}
|
|
721
|
-
const scrollHeight = element.scrollHeight;
|
|
722
|
-
const isScrollable = scrollHeight > clientHeight + 1;
|
|
723
1163
|
rail.hidden = !isScrollable;
|
|
1164
|
+
rail.style.pointerEvents = isScrollable ? '' : 'none';
|
|
724
1165
|
if (!isScrollable) {
|
|
725
|
-
this.thumbLayout =
|
|
1166
|
+
this.thumbLayout = {
|
|
1167
|
+
thumbHeight: 0,
|
|
1168
|
+
maxScroll: 0,
|
|
1169
|
+
maxThumbOffset: 0,
|
|
1170
|
+
clientHeight,
|
|
1171
|
+
scrollHeight,
|
|
1172
|
+
};
|
|
726
1173
|
thumb.style.height = '';
|
|
727
1174
|
thumb.style.top = '';
|
|
728
1175
|
return;
|
|
@@ -730,61 +1177,148 @@ class AXOverlayScrollbarDirective {
|
|
|
730
1177
|
const thumbHeight = Math.max(MIN_THUMB_HEIGHT_PX, (trackViewportHeight / scrollHeight) * trackViewportHeight);
|
|
731
1178
|
const maxScroll = scrollHeight - clientHeight;
|
|
732
1179
|
const maxThumbOffset = Math.max(0, trackViewportHeight - thumbHeight);
|
|
733
|
-
this.thumbLayout = { thumbHeight, maxScroll, maxThumbOffset };
|
|
1180
|
+
this.thumbLayout = { thumbHeight, maxScroll, maxThumbOffset, clientHeight, scrollHeight };
|
|
734
1181
|
thumb.style.height = `${thumbHeight}px`;
|
|
735
|
-
this.
|
|
1182
|
+
this.applyVerticalThumbOffset(element.scrollTop, element.scrollLeft);
|
|
736
1183
|
}
|
|
737
|
-
|
|
738
|
-
const
|
|
1184
|
+
remeasureHorizontalThumb(element) {
|
|
1185
|
+
const rail = this.xRailEl;
|
|
1186
|
+
const thumb = this.xThumbEl;
|
|
1187
|
+
if (!rail || !thumb) {
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
const clientWidth = this.readViewportWidth(element);
|
|
1191
|
+
const scrollWidth = element.scrollWidth;
|
|
1192
|
+
const isScrollable = scrollWidth > clientWidth + 1;
|
|
1193
|
+
const navigationEnabled = this.options.navigationButtons === true && isScrollable;
|
|
1194
|
+
rail.classList.toggle(RAIL_WITH_NAV_CLASS, navigationEnabled);
|
|
1195
|
+
const verticalVisible = this.thumbLayout != null && this.thumbLayout.maxScroll > 0;
|
|
1196
|
+
const thickness = this.railEl ? readRailWidthPx(this.railEl) : DEFAULT_SCROLLBAR_WIDTH_PX;
|
|
1197
|
+
const railWidth = Math.max(0, clientWidth - (verticalVisible ? thickness : 0));
|
|
1198
|
+
rail.style.width = `${railWidth}px`;
|
|
1199
|
+
this.pinRailsToViewport(element.scrollLeft, element.scrollTop);
|
|
1200
|
+
const track = this.xTrackEl;
|
|
1201
|
+
let trackViewportWidth = track?.clientWidth ?? 0;
|
|
1202
|
+
if (trackViewportWidth <= 0) {
|
|
1203
|
+
trackViewportWidth = navigationEnabled ? Math.max(0, railWidth - 2 * thickness) : railWidth;
|
|
1204
|
+
}
|
|
1205
|
+
rail.hidden = !isScrollable;
|
|
1206
|
+
rail.style.pointerEvents = isScrollable ? '' : 'none';
|
|
1207
|
+
if (!isScrollable) {
|
|
1208
|
+
this.xThumbLayout = {
|
|
1209
|
+
thumbWidth: 0,
|
|
1210
|
+
maxScroll: 0,
|
|
1211
|
+
maxThumbOffset: 0,
|
|
1212
|
+
clientWidth,
|
|
1213
|
+
scrollWidth,
|
|
1214
|
+
};
|
|
1215
|
+
thumb.style.width = '';
|
|
1216
|
+
thumb.style.insetInlineStart = '';
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
const thumbWidth = Math.max(MIN_THUMB_HEIGHT_PX, (trackViewportWidth / scrollWidth) * trackViewportWidth);
|
|
1220
|
+
const maxScroll = scrollWidth - clientWidth;
|
|
1221
|
+
const maxThumbOffset = Math.max(0, trackViewportWidth - thumbWidth);
|
|
1222
|
+
this.xThumbLayout = { thumbWidth, maxScroll, maxThumbOffset, clientWidth, scrollWidth };
|
|
1223
|
+
thumb.style.width = `${thumbWidth}px`;
|
|
1224
|
+
this.applyHorizontalThumbOffset(element.scrollLeft, element.scrollTop);
|
|
1225
|
+
}
|
|
1226
|
+
applyVerticalThumbOffset(scrollTop, scrollLeft) {
|
|
739
1227
|
const thumb = this.thumbEl;
|
|
740
1228
|
const layout = this.thumbLayout;
|
|
1229
|
+
this.pinRailsToViewport(scrollLeft, scrollTop);
|
|
741
1230
|
if (!thumb || !layout) {
|
|
742
1231
|
return;
|
|
743
1232
|
}
|
|
744
|
-
const
|
|
745
|
-
const scrollTop = element.scrollTop;
|
|
746
|
-
const thumbOffset = maxScroll > 0 ? (scrollTop / maxScroll) * maxThumbOffset : 0;
|
|
1233
|
+
const thumbOffset = layout.maxScroll > 0 ? (scrollTop / layout.maxScroll) * layout.maxThumbOffset : 0;
|
|
747
1234
|
thumb.style.top = `${thumbOffset}px`;
|
|
748
1235
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
if (!
|
|
1236
|
+
applyHorizontalThumbOffset(scrollLeft, scrollTop) {
|
|
1237
|
+
const thumb = this.xThumbEl;
|
|
1238
|
+
const layout = this.xThumbLayout;
|
|
1239
|
+
this.pinRailsToViewport(scrollLeft, scrollTop);
|
|
1240
|
+
if (!thumb || !layout) {
|
|
754
1241
|
return;
|
|
755
1242
|
}
|
|
756
|
-
const
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
this.
|
|
1243
|
+
const progress = layout.maxScroll > 0 ? Math.abs(scrollLeft) / layout.maxScroll : 0;
|
|
1244
|
+
thumb.style.insetInlineStart = `${progress * layout.maxThumbOffset}px`;
|
|
1245
|
+
}
|
|
1246
|
+
syncThumbPosition(fromScroll = false) {
|
|
1247
|
+
const element = this.getScrollMetricsElement();
|
|
1248
|
+
if (!this.railEl && !this.xRailEl) {
|
|
1249
|
+
return;
|
|
1250
|
+
}
|
|
1251
|
+
if (fromScroll && !this.layoutMetricsChanged(element)) {
|
|
1252
|
+
this.applyVerticalThumbOffset(element.scrollTop, element.scrollLeft);
|
|
1253
|
+
this.applyHorizontalThumbOffset(element.scrollLeft, element.scrollTop);
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
this.remeasureCustomThumb();
|
|
1257
|
+
}
|
|
1258
|
+
/** Move thumb (and scroll position) to the pointer on the track. */
|
|
1259
|
+
jumpScrollToTrackPointer(event, scroller, axis) {
|
|
1260
|
+
if (axis === 'x') {
|
|
1261
|
+
const rail = this.xRailEl;
|
|
1262
|
+
const layout = this.xThumbLayout;
|
|
1263
|
+
if (!rail || !layout || layout.maxScroll <= 0 || layout.maxThumbOffset <= 0) {
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
const track = this.xTrackEl ?? rail;
|
|
1267
|
+
const rect = track.getBoundingClientRect();
|
|
1268
|
+
const offsetX = event.clientX - rect.left;
|
|
1269
|
+
const thumbStart = Math.min(layout.maxThumbOffset, Math.max(0, offsetX - layout.thumbWidth / 2));
|
|
1270
|
+
scroller.scrollLeft = (thumbStart / layout.maxThumbOffset) * layout.maxScroll;
|
|
1271
|
+
}
|
|
1272
|
+
else {
|
|
1273
|
+
const rail = this.railEl;
|
|
1274
|
+
const layout = this.thumbLayout;
|
|
1275
|
+
if (!rail || !layout || layout.maxScroll <= 0 || layout.maxThumbOffset <= 0) {
|
|
1276
|
+
return;
|
|
1277
|
+
}
|
|
1278
|
+
const track = this.trackEl ?? rail;
|
|
1279
|
+
const rect = track.getBoundingClientRect();
|
|
1280
|
+
const offsetY = event.clientY - rect.top;
|
|
1281
|
+
const thumbTop = Math.min(layout.maxThumbOffset, Math.max(0, offsetY - layout.thumbHeight / 2));
|
|
1282
|
+
scroller.scrollTop = (thumbTop / layout.maxThumbOffset) * layout.maxScroll;
|
|
1283
|
+
}
|
|
1284
|
+
this.syncThumbPosition(true);
|
|
762
1285
|
this.bumpVisibility();
|
|
763
1286
|
}
|
|
764
|
-
onThumbPointerDown(event) {
|
|
1287
|
+
onThumbPointerDown(event, axis = 'y') {
|
|
765
1288
|
event.preventDefault();
|
|
766
1289
|
event.stopPropagation();
|
|
767
|
-
const element = this.
|
|
768
|
-
const thumb = this.thumbEl;
|
|
1290
|
+
const element = this.getScrollMetricsElement();
|
|
1291
|
+
const thumb = axis === 'x' ? this.xThumbEl : this.thumbEl;
|
|
769
1292
|
if (!thumb) {
|
|
770
1293
|
return;
|
|
771
1294
|
}
|
|
772
1295
|
this.setScrollbarEngaged(true);
|
|
773
1296
|
this.bumpVisibility();
|
|
774
1297
|
thumb.setPointerCapture(event.pointerId);
|
|
1298
|
+
const startX = event.clientX;
|
|
775
1299
|
const startY = event.clientY;
|
|
1300
|
+
const startScrollLeft = element.scrollLeft;
|
|
776
1301
|
const startScrollTop = element.scrollTop;
|
|
777
|
-
const
|
|
778
|
-
const
|
|
779
|
-
const
|
|
780
|
-
const
|
|
1302
|
+
const yLayout = this.thumbLayout;
|
|
1303
|
+
const xLayout = this.xThumbLayout;
|
|
1304
|
+
const maxScrollY = yLayout?.maxScroll ?? element.scrollHeight - element.clientHeight;
|
|
1305
|
+
const maxThumbOffsetY = yLayout?.maxThumbOffset ?? element.clientHeight - thumb.offsetHeight;
|
|
1306
|
+
const maxScrollX = xLayout?.maxScroll ?? element.scrollWidth - element.clientWidth;
|
|
1307
|
+
const maxThumbOffsetX = xLayout?.maxThumbOffset ?? element.clientWidth - thumb.offsetWidth;
|
|
781
1308
|
const onPointerMove = (moveEvent) => {
|
|
782
|
-
if (
|
|
1309
|
+
if (axis === 'x') {
|
|
1310
|
+
if (maxThumbOffsetX <= 0 || maxScrollX <= 0) {
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
const deltaX = moveEvent.clientX - startX;
|
|
1314
|
+
element.scrollLeft = startScrollLeft + (deltaX / maxThumbOffsetX) * maxScrollX;
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
if (maxThumbOffsetY <= 0 || maxScrollY <= 0) {
|
|
783
1318
|
return;
|
|
784
1319
|
}
|
|
785
1320
|
const deltaY = moveEvent.clientY - startY;
|
|
786
|
-
|
|
787
|
-
element.scrollTop = startScrollTop + scrollDelta;
|
|
1321
|
+
element.scrollTop = startScrollTop + (deltaY / maxThumbOffsetY) * maxScrollY;
|
|
788
1322
|
};
|
|
789
1323
|
const onPointerUp = (upEvent) => {
|
|
790
1324
|
thumb.releasePointerCapture(upEvent.pointerId);
|
|
@@ -800,36 +1334,57 @@ class AXOverlayScrollbarDirective {
|
|
|
800
1334
|
thumb.addEventListener('pointercancel', onPointerUp);
|
|
801
1335
|
}
|
|
802
1336
|
showScrollbar() {
|
|
803
|
-
this.
|
|
1337
|
+
if (this.isDocumentScrollAttachment()) {
|
|
1338
|
+
this.rootEl?.classList.add(VISIBLE_CLASS);
|
|
1339
|
+
this.document.body.classList.add(VISIBLE_CLASS);
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
this.hostEl.classList.add(VISIBLE_CLASS);
|
|
804
1343
|
this.rootEl?.classList.add(VISIBLE_CLASS);
|
|
805
1344
|
}
|
|
806
1345
|
bumpVisibility() {
|
|
807
1346
|
this.showScrollbar();
|
|
808
|
-
if (this.pointerOverRail) {
|
|
1347
|
+
if (this.pointerOverRail || this.thumbDragPointerId !== null) {
|
|
809
1348
|
this.clearHideTimer();
|
|
810
1349
|
return;
|
|
811
1350
|
}
|
|
812
1351
|
this.scheduleHide();
|
|
813
1352
|
}
|
|
814
1353
|
deactivateThumb() {
|
|
815
|
-
if (this.pointerOverRail) {
|
|
1354
|
+
if (this.pointerOverRail || this.thumbDragPointerId !== null) {
|
|
816
1355
|
return;
|
|
817
1356
|
}
|
|
818
1357
|
this.clearHideTimer();
|
|
819
|
-
this.
|
|
820
|
-
|
|
1358
|
+
if (this.isDocumentScrollAttachment()) {
|
|
1359
|
+
this.rootEl?.classList.remove(VISIBLE_CLASS);
|
|
1360
|
+
this.document.body.classList.remove(VISIBLE_CLASS);
|
|
1361
|
+
}
|
|
1362
|
+
else {
|
|
1363
|
+
this.hostEl.classList.remove(VISIBLE_CLASS);
|
|
1364
|
+
this.rootEl?.classList.remove(VISIBLE_CLASS);
|
|
1365
|
+
}
|
|
821
1366
|
this.setScrollbarEngaged(false);
|
|
822
1367
|
}
|
|
823
1368
|
setScrollbarEngaged(engaged) {
|
|
824
|
-
this.
|
|
1369
|
+
if (this.isDocumentScrollAttachment()) {
|
|
1370
|
+
this.rootEl?.classList.toggle(ENGAGED_CLASS, engaged);
|
|
1371
|
+
this.document.body.classList.toggle(ENGAGED_CLASS, engaged);
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
this.hostEl.classList.toggle(ENGAGED_CLASS, engaged);
|
|
825
1375
|
this.rootEl?.classList.toggle(ENGAGED_CLASS, engaged);
|
|
826
1376
|
}
|
|
827
1377
|
setTrackPressed(pressed) {
|
|
828
|
-
this.
|
|
1378
|
+
if (this.isDocumentScrollAttachment()) {
|
|
1379
|
+
this.rootEl?.classList.toggle(TRACK_PRESSED_CLASS, pressed);
|
|
1380
|
+
this.document.body.classList.toggle(TRACK_PRESSED_CLASS, pressed);
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
this.hostEl.classList.toggle(TRACK_PRESSED_CLASS, pressed);
|
|
829
1384
|
this.rootEl?.classList.toggle(TRACK_PRESSED_CLASS, pressed);
|
|
830
1385
|
}
|
|
831
|
-
isPointerOverThumbVisual(clientX, clientY) {
|
|
832
|
-
const thumb = this.thumbEl;
|
|
1386
|
+
isPointerOverThumbVisual(clientX, clientY, axis = 'y') {
|
|
1387
|
+
const thumb = axis === 'x' ? this.xThumbEl : this.thumbEl;
|
|
833
1388
|
if (!thumb) {
|
|
834
1389
|
return false;
|
|
835
1390
|
}
|
|
@@ -864,12 +1419,12 @@ class AXOverlayScrollbarDirective {
|
|
|
864
1419
|
this.setScrollbarEngaged(false);
|
|
865
1420
|
}
|
|
866
1421
|
scheduleHide() {
|
|
867
|
-
if (this.pointerOverRail) {
|
|
1422
|
+
if (this.pointerOverRail || this.thumbDragPointerId !== null) {
|
|
868
1423
|
this.clearHideTimer();
|
|
869
1424
|
return;
|
|
870
1425
|
}
|
|
871
1426
|
this.clearHideTimer();
|
|
872
|
-
const delay = Math.max(0, this.hideDelay
|
|
1427
|
+
const delay = Math.max(0, this.options.hideDelay);
|
|
873
1428
|
this.hideTimer = setTimeout(() => {
|
|
874
1429
|
this.deactivateThumb();
|
|
875
1430
|
this.hideTimer = null;
|
|
@@ -881,8 +1436,92 @@ class AXOverlayScrollbarDirective {
|
|
|
881
1436
|
this.hideTimer = null;
|
|
882
1437
|
}
|
|
883
1438
|
}
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* Manual opt-in on a host. With {@link provideOverlayScrollbar} enabled, overflow hosts are attached automatically.
|
|
1442
|
+
*/
|
|
1443
|
+
class AXOverlayScrollbarDirective {
|
|
1444
|
+
overlayChromeActive() {
|
|
1445
|
+
return this.isOverlayEnabled() && this.overlayMounted;
|
|
1446
|
+
}
|
|
1447
|
+
isOverlayEnabled() {
|
|
1448
|
+
const local = this.enabled();
|
|
1449
|
+
if (local !== undefined) {
|
|
1450
|
+
return local;
|
|
1451
|
+
}
|
|
1452
|
+
return this.appConfig.enabled;
|
|
1453
|
+
}
|
|
1454
|
+
constructor() {
|
|
1455
|
+
this.host = inject(ElementRef);
|
|
1456
|
+
this.destroyRef = inject(DestroyRef);
|
|
1457
|
+
this.platformId = inject(PLATFORM_ID);
|
|
1458
|
+
this.document = inject(DOCUMENT);
|
|
1459
|
+
this.appConfig = inject(AX_OVERLAY_SCROLLBAR_CONFIG);
|
|
1460
|
+
this.hideDelay = input(this.appConfig.hideDelay, /* @ts-ignore */
|
|
1461
|
+
...(ngDevMode ? [{ debugName: "hideDelay" }] : /* istanbul ignore next */ []));
|
|
1462
|
+
this.navigationButtons = input(this.appConfig.navigationButtons, /* @ts-ignore */
|
|
1463
|
+
...(ngDevMode ? [{ debugName: "navigationButtons" }] : /* istanbul ignore next */ []));
|
|
1464
|
+
this.navScrollStep = input(this.appConfig.navScrollStep, /* @ts-ignore */
|
|
1465
|
+
...(ngDevMode ? [{ debugName: "navScrollStep" }] : /* istanbul ignore next */ []));
|
|
1466
|
+
this.enabled = input(undefined, { ...(ngDevMode ? { debugName: "enabled" } : /* istanbul ignore next */ {}), alias: 'axOverlayScrollbarEnabled' });
|
|
1467
|
+
this.documentScroll = input(false, { ...(ngDevMode ? { debugName: "documentScroll" } : /* istanbul ignore next */ {}), alias: 'axOverlayScrollbarDocument' });
|
|
1468
|
+
this.runtime = null;
|
|
1469
|
+
this.overlayMounted = false;
|
|
1470
|
+
this.destroyRef.onDestroy(() => this.deactivateOverlay());
|
|
1471
|
+
afterRenderEffect(() => {
|
|
1472
|
+
if (!isPlatformBrowser(this.platformId)) {
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
if (this.isOverlayEnabled()) {
|
|
1476
|
+
this.activateOverlay();
|
|
1477
|
+
}
|
|
1478
|
+
else {
|
|
1479
|
+
this.deactivateOverlay();
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
effect(() => {
|
|
1483
|
+
if (!isPlatformBrowser(this.platformId) || !this.isOverlayEnabled()) {
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
this.activateOverlay();
|
|
1487
|
+
this.runtime?.updateOptions({
|
|
1488
|
+
hideDelay: this.hideDelay(),
|
|
1489
|
+
navigationButtons: this.navigationButtons(),
|
|
1490
|
+
navScrollStep: this.navScrollStep(),
|
|
1491
|
+
});
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
activateOverlay() {
|
|
1495
|
+
const host = this.host.nativeElement;
|
|
1496
|
+
const existing = OVERLAY_SCROLLBAR_RUNTIMES.get(host);
|
|
1497
|
+
if (existing?.isAttached()) {
|
|
1498
|
+
this.runtime = existing;
|
|
1499
|
+
this.overlayMounted = true;
|
|
1500
|
+
return;
|
|
1501
|
+
}
|
|
1502
|
+
if (this.runtime?.isAttached()) {
|
|
1503
|
+
this.overlayMounted = true;
|
|
1504
|
+
return;
|
|
1505
|
+
}
|
|
1506
|
+
this.runtime = new AXOverlayScrollbarRuntime(host, this.document, this.appConfig, {
|
|
1507
|
+
hideDelay: this.hideDelay(),
|
|
1508
|
+
navigationButtons: this.navigationButtons(),
|
|
1509
|
+
navScrollStep: this.navScrollStep(),
|
|
1510
|
+
documentScroll: this.documentScroll(),
|
|
1511
|
+
});
|
|
1512
|
+
this.overlayMounted = this.runtime.attach();
|
|
1513
|
+
if (!this.overlayMounted) {
|
|
1514
|
+
this.runtime = OVERLAY_SCROLLBAR_RUNTIMES.get(host) ?? null;
|
|
1515
|
+
this.overlayMounted = this.runtime?.isAttached() === true;
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
deactivateOverlay() {
|
|
1519
|
+
this.runtime?.detach();
|
|
1520
|
+
this.runtime = null;
|
|
1521
|
+
this.overlayMounted = false;
|
|
1522
|
+
}
|
|
884
1523
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXOverlayScrollbarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
885
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.6", type: AXOverlayScrollbarDirective, isStandalone: true, selector: "[axOverlayScrollbar]", inputs: { hideDelay: { classPropertyName: "hideDelay", publicName: "hideDelay", isSignal: true, isRequired: false, transformFunction: null }, navigationButtons: { classPropertyName: "navigationButtons", publicName: "navigationButtons", isSignal: true, isRequired: false, transformFunction: null }, navScrollStep: { classPropertyName: "navScrollStep", publicName: "navScrollStep", isSignal: true, isRequired: false, transformFunction: null } }, host: {
|
|
1524
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.6", type: AXOverlayScrollbarDirective, isStandalone: true, selector: "[axOverlayScrollbar]", inputs: { hideDelay: { classPropertyName: "hideDelay", publicName: "hideDelay", isSignal: true, isRequired: false, transformFunction: null }, navigationButtons: { classPropertyName: "navigationButtons", publicName: "navigationButtons", isSignal: true, isRequired: false, transformFunction: null }, navScrollStep: { classPropertyName: "navScrollStep", publicName: "navScrollStep", isSignal: true, isRequired: false, transformFunction: null }, enabled: { classPropertyName: "enabled", publicName: "axOverlayScrollbarEnabled", isSignal: true, isRequired: false, transformFunction: null }, documentScroll: { classPropertyName: "documentScroll", publicName: "axOverlayScrollbarDocument", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.ax-cdk-overlay-scrollbar": "overlayChromeActive()" } }, exportAs: ["axOverlayScrollbar"], ngImport: i0 }); }
|
|
886
1525
|
}
|
|
887
1526
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXOverlayScrollbarDirective, decorators: [{
|
|
888
1527
|
type: Directive,
|
|
@@ -890,14 +1529,283 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
|
|
|
890
1529
|
selector: '[axOverlayScrollbar]',
|
|
891
1530
|
exportAs: 'axOverlayScrollbar',
|
|
892
1531
|
host: {
|
|
893
|
-
class
|
|
1532
|
+
'[class.ax-cdk-overlay-scrollbar]': 'overlayChromeActive()',
|
|
894
1533
|
},
|
|
895
1534
|
}]
|
|
896
|
-
}], ctorParameters: () => [], propDecorators: { hideDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideDelay", required: false }] }], navigationButtons: [{ type: i0.Input, args: [{ isSignal: true, alias: "navigationButtons", required: false }] }], navScrollStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "navScrollStep", required: false }] }] } });
|
|
1535
|
+
}], ctorParameters: () => [], propDecorators: { hideDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideDelay", required: false }] }], navigationButtons: [{ type: i0.Input, args: [{ isSignal: true, alias: "navigationButtons", required: false }] }], navScrollStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "navScrollStep", required: false }] }], enabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "axOverlayScrollbarEnabled", required: false }] }], documentScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "axOverlayScrollbarDocument", required: false }] }] } });
|
|
1536
|
+
|
|
1537
|
+
/**
|
|
1538
|
+
* Applies {@link AXOverlayScrollbarDirective} to CDK virtual scroll viewports (lists, lookup, data-list, …).
|
|
1539
|
+
* Import {@link AX_OVERLAY_SCROLLBAR_VIRTUAL_SCROLL_IMPORTS} (or this directive) on the owning component.
|
|
1540
|
+
*/
|
|
1541
|
+
class AXCdkVirtualScrollViewportOverlayDirective {
|
|
1542
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXCdkVirtualScrollViewportOverlayDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1543
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.6", type: AXCdkVirtualScrollViewportOverlayDirective, isStandalone: true, selector: "cdk-virtual-scroll-viewport:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled])", hostDirectives: [{ directive: AXOverlayScrollbarDirective }], ngImport: i0 }); }
|
|
1544
|
+
}
|
|
1545
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXCdkVirtualScrollViewportOverlayDirective, decorators: [{
|
|
1546
|
+
type: Directive,
|
|
1547
|
+
args: [{
|
|
1548
|
+
selector: 'cdk-virtual-scroll-viewport:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled])',
|
|
1549
|
+
hostDirectives: [AXOverlayScrollbarDirective],
|
|
1550
|
+
}]
|
|
1551
|
+
}] });
|
|
1552
|
+
/**
|
|
1553
|
+
* Known internal Acorex scroll panels. Must be imported on the component whose template
|
|
1554
|
+
* contains the matching scroll host — class selectors do not apply across unrelated templates.
|
|
1555
|
+
*/
|
|
1556
|
+
class AXAcorexOverlayScrollHostDirective {
|
|
1557
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXAcorexOverlayScrollHostDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1558
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.6", type: AXAcorexOverlayScrollHostDirective, isStandalone: true, selector: "\n .ax-popup-body-container:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),\n .ax-combo-box-listbox:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),\n .ax-tags-scroll:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),\n .ax-data-table-wrapper:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),\n .ax-lookup-tree:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),\n .ax-menu-items:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),\n .ax-command-container:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),\n .ax-action-list:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled])\n ", hostDirectives: [{ directive: AXOverlayScrollbarDirective }], ngImport: i0 }); }
|
|
1559
|
+
}
|
|
1560
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXAcorexOverlayScrollHostDirective, decorators: [{
|
|
1561
|
+
type: Directive,
|
|
1562
|
+
args: [{
|
|
1563
|
+
selector: `
|
|
1564
|
+
.ax-popup-body-container:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),
|
|
1565
|
+
.ax-combo-box-listbox:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),
|
|
1566
|
+
.ax-tags-scroll:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),
|
|
1567
|
+
.ax-data-table-wrapper:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),
|
|
1568
|
+
.ax-lookup-tree:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),
|
|
1569
|
+
.ax-menu-items:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),
|
|
1570
|
+
.ax-command-container:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled]),
|
|
1571
|
+
.ax-action-list:not([axOverlayScrollbar]):not([axOverlayScrollbarDisabled])
|
|
1572
|
+
`,
|
|
1573
|
+
hostDirectives: [AXOverlayScrollbarDirective],
|
|
1574
|
+
}]
|
|
1575
|
+
}] });
|
|
1576
|
+
/** CDK scrolling plus automatic overlay scrollbar on virtual viewports. */
|
|
1577
|
+
const AX_OVERLAY_SCROLLBAR_VIRTUAL_SCROLL_IMPORTS = [
|
|
1578
|
+
ScrollingModule,
|
|
1579
|
+
AXCdkVirtualScrollViewportOverlayDirective,
|
|
1580
|
+
];
|
|
1581
|
+
/** Scroll-host bridge directives for Acorex shells (popup, combo, tag-box, …). */
|
|
1582
|
+
const AX_OVERLAY_SCROLLBAR_ACOREX_SCROLL_HOST_IMPORTS = [
|
|
1583
|
+
AXAcorexOverlayScrollHostDirective,
|
|
1584
|
+
];
|
|
1585
|
+
|
|
1586
|
+
const SKIP_TAGS = new Set([
|
|
1587
|
+
'TEXTAREA',
|
|
1588
|
+
'SELECT',
|
|
1589
|
+
'INPUT',
|
|
1590
|
+
'OPTION',
|
|
1591
|
+
'SCRIPT',
|
|
1592
|
+
'STYLE',
|
|
1593
|
+
'LINK',
|
|
1594
|
+
'META',
|
|
1595
|
+
'HEAD',
|
|
1596
|
+
'BR',
|
|
1597
|
+
'HR',
|
|
1598
|
+
'IMG',
|
|
1599
|
+
'SVG',
|
|
1600
|
+
'CANVAS',
|
|
1601
|
+
'VIDEO',
|
|
1602
|
+
'AUDIO',
|
|
1603
|
+
'IFRAME',
|
|
1604
|
+
'NOSCRIPT',
|
|
1605
|
+
'TEMPLATE',
|
|
1606
|
+
'AX-RAIL-NAVIGATION-ITEM',
|
|
1607
|
+
]);
|
|
1608
|
+
const CSS_OVERFLOW_SCROLL = new Set(['auto', 'scroll', 'overlay']);
|
|
1609
|
+
/**
|
|
1610
|
+
* Attaches overlay scrollbars to overflow hosts when {@link provideOverlayScrollbar} is enabled.
|
|
1611
|
+
* Uses computed overflow so library components do not import overlay directives.
|
|
1612
|
+
*/
|
|
1613
|
+
class AXOverlayScrollbarAutoAttachService {
|
|
1614
|
+
constructor() {
|
|
1615
|
+
this.platformId = inject(PLATFORM_ID);
|
|
1616
|
+
this.document = inject(DOCUMENT);
|
|
1617
|
+
this.zone = inject(NgZone);
|
|
1618
|
+
this.config = inject(AX_OVERLAY_SCROLLBAR_CONFIG);
|
|
1619
|
+
this.attachments = new Map();
|
|
1620
|
+
this.observer = null;
|
|
1621
|
+
this.started = false;
|
|
1622
|
+
this.pending = new Set();
|
|
1623
|
+
this.flushHandle = 0;
|
|
1624
|
+
}
|
|
1625
|
+
start() {
|
|
1626
|
+
if (this.started || !isPlatformBrowser(this.platformId) || !this.config.enabled) {
|
|
1627
|
+
return;
|
|
1628
|
+
}
|
|
1629
|
+
this.started = true;
|
|
1630
|
+
this.zone.runOutsideAngular(() => {
|
|
1631
|
+
const root = this.document.body ?? this.document.documentElement;
|
|
1632
|
+
if (!root) {
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
this.scan(root);
|
|
1636
|
+
this.observer = new MutationObserver((records) => this.onMutations(records));
|
|
1637
|
+
this.observer.observe(root, {
|
|
1638
|
+
childList: true,
|
|
1639
|
+
subtree: true,
|
|
1640
|
+
attributes: true,
|
|
1641
|
+
attributeFilter: [
|
|
1642
|
+
'class',
|
|
1643
|
+
'style',
|
|
1644
|
+
'axOverlayScrollbar',
|
|
1645
|
+
'axoverlayscrollbar',
|
|
1646
|
+
'axOverlayScrollbarDisabled',
|
|
1647
|
+
'axoverlayscrollbardisabled',
|
|
1648
|
+
],
|
|
1649
|
+
});
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
onMutations(records) {
|
|
1653
|
+
for (const record of records) {
|
|
1654
|
+
if (record.type === 'attributes' && record.target instanceof Node) {
|
|
1655
|
+
this.pending.add(record.target);
|
|
1656
|
+
}
|
|
1657
|
+
for (const node of record.addedNodes) {
|
|
1658
|
+
this.pending.add(node);
|
|
1659
|
+
}
|
|
1660
|
+
for (const node of record.removedNodes) {
|
|
1661
|
+
if (node instanceof HTMLElement) {
|
|
1662
|
+
this.unmountTree(node);
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
this.scheduleFlush();
|
|
1667
|
+
}
|
|
1668
|
+
scheduleFlush() {
|
|
1669
|
+
if (this.flushHandle) {
|
|
1670
|
+
return;
|
|
1671
|
+
}
|
|
1672
|
+
this.flushHandle = requestAnimationFrame(() => {
|
|
1673
|
+
this.flushHandle = 0;
|
|
1674
|
+
const nodes = [...this.pending];
|
|
1675
|
+
this.pending.clear();
|
|
1676
|
+
for (const node of nodes) {
|
|
1677
|
+
this.scan(node);
|
|
1678
|
+
}
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
scan(root) {
|
|
1682
|
+
if (root instanceof HTMLElement) {
|
|
1683
|
+
this.consider(root);
|
|
1684
|
+
}
|
|
1685
|
+
if (!(root instanceof Element || root instanceof DocumentFragment || root instanceof Document)) {
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
root.querySelectorAll('*').forEach((node) => {
|
|
1689
|
+
if (node instanceof HTMLElement) {
|
|
1690
|
+
this.consider(node);
|
|
1691
|
+
}
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
consider(el) {
|
|
1695
|
+
if (this.shouldAttach(el)) {
|
|
1696
|
+
this.mount(el);
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
if (this.attachments.has(el)) {
|
|
1700
|
+
this.unmount(el);
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
unmountTree(root) {
|
|
1704
|
+
this.unmount(root);
|
|
1705
|
+
for (const [el, runtime] of [...this.attachments]) {
|
|
1706
|
+
if (el === root || root.contains(el)) {
|
|
1707
|
+
runtime.detach();
|
|
1708
|
+
this.attachments.delete(el);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
shouldAttach(el) {
|
|
1713
|
+
if (SKIP_TAGS.has(el.tagName)) {
|
|
1714
|
+
return false;
|
|
1715
|
+
}
|
|
1716
|
+
if (el === this.document.documentElement || el === this.document.body) {
|
|
1717
|
+
return false;
|
|
1718
|
+
}
|
|
1719
|
+
if (el.classList.contains('ax-cdk-overlay-scrollbar__rail') || el.closest('.ax-cdk-overlay-scrollbar__rail')) {
|
|
1720
|
+
return false;
|
|
1721
|
+
}
|
|
1722
|
+
if (el.hasAttribute('axOverlayScrollbarDisabled') || el.hasAttribute('axoverlayscrollbardisabled')) {
|
|
1723
|
+
return false;
|
|
1724
|
+
}
|
|
1725
|
+
if (el.hasAttribute(AX_OVERLAY_SCROLLBAR_HOST_INIT_ATTR) && !this.attachments.has(el)) {
|
|
1726
|
+
return false;
|
|
1727
|
+
}
|
|
1728
|
+
if (el.hasAttribute('axOverlayScrollbar') || el.hasAttribute('axoverlayscrollbar')) {
|
|
1729
|
+
return this.attachments.has(el);
|
|
1730
|
+
}
|
|
1731
|
+
return this.hasCssOverflow(el);
|
|
1732
|
+
}
|
|
1733
|
+
hasCssOverflow(el) {
|
|
1734
|
+
if (!el.isConnected) {
|
|
1735
|
+
return false;
|
|
1736
|
+
}
|
|
1737
|
+
const style = getComputedStyle(el);
|
|
1738
|
+
return CSS_OVERFLOW_SCROLL.has(style.overflowY) || CSS_OVERFLOW_SCROLL.has(style.overflowX);
|
|
1739
|
+
}
|
|
1740
|
+
mount(el) {
|
|
1741
|
+
if (this.attachments.has(el)) {
|
|
1742
|
+
return;
|
|
1743
|
+
}
|
|
1744
|
+
const runtime = new AXOverlayScrollbarRuntime(el, this.document, this.config, {
|
|
1745
|
+
hideDelay: this.config.hideDelay,
|
|
1746
|
+
navigationButtons: this.config.navigationButtons,
|
|
1747
|
+
navScrollStep: this.config.navScrollStep,
|
|
1748
|
+
});
|
|
1749
|
+
if (!runtime.attach()) {
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
this.attachments.set(el, runtime);
|
|
1753
|
+
}
|
|
1754
|
+
unmount(el) {
|
|
1755
|
+
const runtime = this.attachments.get(el);
|
|
1756
|
+
if (!runtime) {
|
|
1757
|
+
return;
|
|
1758
|
+
}
|
|
1759
|
+
runtime.detach();
|
|
1760
|
+
this.attachments.delete(el);
|
|
1761
|
+
}
|
|
1762
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXOverlayScrollbarAutoAttachService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1763
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXOverlayScrollbarAutoAttachService, providedIn: 'root' }); }
|
|
1764
|
+
}
|
|
1765
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXOverlayScrollbarAutoAttachService, decorators: [{
|
|
1766
|
+
type: Injectable,
|
|
1767
|
+
args: [{ providedIn: 'root' }]
|
|
1768
|
+
}] });
|
|
1769
|
+
|
|
1770
|
+
let rootDesignTokenSnapshot = null;
|
|
1771
|
+
/**
|
|
1772
|
+
* Registers overlay scrollbar application config and attaches overlay scrollbars to overflow hosts.
|
|
1773
|
+
*
|
|
1774
|
+
* When `enabled` is omitted, it defaults to `true` (opt-in by calling this function).
|
|
1775
|
+
* Without this provider, {@link AX_OVERLAY_SCROLLBAR_CONFIG} stays disabled and native scrollbars remain.
|
|
1776
|
+
*/
|
|
1777
|
+
function provideOverlayScrollbar(config = {}) {
|
|
1778
|
+
const merged = overlayScrollbarConfig(config);
|
|
1779
|
+
return makeEnvironmentProviders([
|
|
1780
|
+
{
|
|
1781
|
+
provide: AX_OVERLAY_SCROLLBAR_CONFIG,
|
|
1782
|
+
useValue: merged,
|
|
1783
|
+
},
|
|
1784
|
+
provideEnvironmentInitializer(() => {
|
|
1785
|
+
if (!merged.enabled) {
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
const platformId = inject(PLATFORM_ID);
|
|
1789
|
+
if (!isPlatformBrowser(platformId)) {
|
|
1790
|
+
return;
|
|
1791
|
+
}
|
|
1792
|
+
const document = inject(DOCUMENT);
|
|
1793
|
+
if (merged.designTokens) {
|
|
1794
|
+
rootDesignTokenSnapshot = applyOverlayScrollbarDesignTokens(document.documentElement, merged.designTokens);
|
|
1795
|
+
}
|
|
1796
|
+
inject(AXOverlayScrollbarAutoAttachService).start();
|
|
1797
|
+
}),
|
|
1798
|
+
]);
|
|
1799
|
+
}
|
|
1800
|
+
/** Restores `:root` tokens written by {@link provideOverlayScrollbar}. Used in tests and teardown. */
|
|
1801
|
+
function restoreProvidedOverlayScrollbarDesignTokens(element) {
|
|
1802
|
+
restoreOverlayScrollbarDesignTokens(element, rootDesignTokenSnapshot);
|
|
1803
|
+
rootDesignTokenSnapshot = null;
|
|
1804
|
+
}
|
|
897
1805
|
|
|
898
1806
|
/**
|
|
899
1807
|
* Generated bundle index. Do not edit.
|
|
900
1808
|
*/
|
|
901
1809
|
|
|
902
|
-
export { AXOverlayScrollbarDefaultConfig, AXOverlayScrollbarDirective, AX_OVERLAY_SCROLLBAR_CONFIG, AX_OVERLAY_SCROLLBAR_CSS_VARS, AX_OVERLAY_SCROLLBAR_DEFAULT_HIDE_DELAY_MS, AX_OVERLAY_SCROLLBAR_DEFAULT_NAV_SCROLL_STEP_PX, applyOverlayScrollbarDesignTokens, clampOverlayScrollbarWidth, overlayScrollbarConfig, provideOverlayScrollbar };
|
|
1810
|
+
export { AXAcorexOverlayScrollHostDirective, AXCdkVirtualScrollViewportOverlayDirective, AXOverlayScrollbarAbsentConfig, AXOverlayScrollbarDefaultConfig, AXOverlayScrollbarDirective, AXOverlayScrollbarRuntime, AX_OVERLAY_SCROLLBAR_ACOREX_SCROLL_HOST_IMPORTS, AX_OVERLAY_SCROLLBAR_CONFIG, AX_OVERLAY_SCROLLBAR_CSS_VARS, AX_OVERLAY_SCROLLBAR_DEFAULT_HIDE_DELAY_MS, AX_OVERLAY_SCROLLBAR_DEFAULT_NAV_SCROLL_STEP_PX, AX_OVERLAY_SCROLLBAR_HOST_INIT_ATTR, AX_OVERLAY_SCROLLBAR_VIRTUAL_SCROLL_IMPORTS, applyOverlayScrollbarDesignTokens, clampOverlayScrollbarWidth, overlayScrollbarConfig, provideOverlayScrollbar, releaseOverlayDocumentNativeHide, releaseOverlayScrollbarStyles, resetOverlayDocumentNativeHideRefCount, resetOverlayScrollbarStyleRefCount, restoreOverlayScrollbarDesignTokens, restoreProvidedOverlayScrollbarDesignTokens, retainOverlayDocumentNativeHide, retainOverlayScrollbarStyles };
|
|
903
1811
|
//# sourceMappingURL=acorex-cdk-overlay-scrollbar.mjs.map
|