@inizioevoke/astro-core 1.3.4 → 1.3.6
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
CHANGED
|
@@ -5,8 +5,13 @@ export interface IScrollContainer {
|
|
|
5
5
|
refresh(): void;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
interface ScrollbarSettings {
|
|
9
|
+
trackVisible?: boolean;
|
|
10
|
+
thumbHeight?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
class ScrollContainer implements IScrollContainer {
|
|
9
|
-
#container: HTMLElement;
|
|
14
|
+
#container: HTMLElement & { evoScrollContainer: ScrollContainer };
|
|
10
15
|
#content: HTMLElement;
|
|
11
16
|
#track: HTMLElement;
|
|
12
17
|
#thumb: HTMLElement;
|
|
@@ -14,12 +19,14 @@ class ScrollContainer implements IScrollContainer {
|
|
|
14
19
|
#startY: number;
|
|
15
20
|
#startScrollTop: number;
|
|
16
21
|
|
|
22
|
+
#scrollbarSettings: ScrollbarSettings = {};
|
|
17
23
|
#mouseupHandler: any = undefined;
|
|
18
24
|
#mousemoveHandler: any = undefined;
|
|
19
25
|
|
|
20
26
|
constructor(container: HTMLElement) {
|
|
21
27
|
// const _this = this;
|
|
22
|
-
this.#container = container;
|
|
28
|
+
this.#container = container as HTMLElement & { evoScrollContainer: ScrollContainer };
|
|
29
|
+
this.#container.evoScrollContainer = this;
|
|
23
30
|
this.#content = container.querySelector('.evo-scroll-content') as HTMLElement;
|
|
24
31
|
this.#track = container.querySelector('.evo-scroll-track') as HTMLElement;
|
|
25
32
|
this.#thumb = container.querySelector('.evo-scroll-thumb') as HTMLElement;
|
|
@@ -78,6 +85,13 @@ class ScrollContainer implements IScrollContainer {
|
|
|
78
85
|
}
|
|
79
86
|
}
|
|
80
87
|
|
|
88
|
+
configureScrollbar({ trackVisible, thumbHeight }: ScrollbarSettings) {
|
|
89
|
+
this.#scrollbarSettings = { trackVisible, thumbHeight };
|
|
90
|
+
this.refresh();
|
|
91
|
+
}
|
|
92
|
+
resetScrollbar() {
|
|
93
|
+
this.configureScrollbar({});
|
|
94
|
+
}
|
|
81
95
|
refresh() {
|
|
82
96
|
this.#updateThumbSize();
|
|
83
97
|
}
|
|
@@ -87,8 +101,17 @@ class ScrollContainer implements IScrollContainer {
|
|
|
87
101
|
const containerHeight = this.#container.clientHeight - getPaddingY(this.#container);
|
|
88
102
|
const visibleRatio = containerHeight / scrollHeight;
|
|
89
103
|
const thumbHeight = visibleRatio * containerHeight;
|
|
90
|
-
this.#
|
|
91
|
-
|
|
104
|
+
if (this.#scrollbarSettings.thumbHeight != undefined) {
|
|
105
|
+
this.#thumb.style.height = `${this.#scrollbarSettings.thumbHeight < 0 ? 0 : this.#scrollbarSettings.thumbHeight > containerHeight ? containerHeight : this.#scrollbarSettings.thumbHeight}px`;
|
|
106
|
+
} else {
|
|
107
|
+
this.#thumb.style.height = `${thumbHeight > 20 ? thumbHeight : 20}px`;
|
|
108
|
+
}
|
|
109
|
+
if (this.#scrollbarSettings.trackVisible !== undefined) {
|
|
110
|
+
this.#track.style.display = this.#scrollbarSettings.trackVisible === true ? 'block' : 'none';
|
|
111
|
+
} else {
|
|
112
|
+
this.#track.style.display = visibleRatio < 1 ? 'block' : 'none';
|
|
113
|
+
}
|
|
114
|
+
|
|
92
115
|
}
|
|
93
116
|
|
|
94
117
|
#thumbMouseDown(e: MouseEvent) {
|
|
@@ -129,7 +129,7 @@ const getFilePaths = (() => {
|
|
|
129
129
|
interface IntegrationProps {
|
|
130
130
|
enabled?: boolean;
|
|
131
131
|
}
|
|
132
|
-
export default function ({ enabled = true }: IntegrationProps): AstroIntegration {
|
|
132
|
+
export default function ({ enabled = true }: IntegrationProps = {}): AstroIntegration {
|
|
133
133
|
let astroConfig: AstroConfig;
|
|
134
134
|
|
|
135
135
|
return {
|