@inizioevoke/astro-core 2.1.1 → 2.1.2
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
|
@@ -198,45 +198,49 @@ export class EvoScrollContainerElement extends HTMLElement implements IEvoScroll
|
|
|
198
198
|
if (this.#thumbVert && this.#trackVert) {
|
|
199
199
|
const scrollHeight = this.#content.scrollHeight - getPaddingY(this.#content);
|
|
200
200
|
const containerHeight = this.clientHeight - getPaddingY(this);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
this.#
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
201
|
+
|
|
202
|
+
if ((containerHeight / scrollHeight) < 1 || this.#scrollbarSettings.trackVisible === true) { // should scroll
|
|
203
|
+
const trackHeight = this.#trackVert.clientHeight;
|
|
204
|
+
const trackStyle = getComputedStyle(this.#trackVert);
|
|
205
|
+
const trackTop = parseInt(trackStyle.getPropertyValue('--evo-scroll-container-track-vert-top'), 10);
|
|
206
|
+
const trackBot = parseInt(trackStyle.getPropertyValue('--evo-scroll-container-track-vert-bottom'), 10);
|
|
207
|
+
const trackOffset = parseInt(trackStyle.getPropertyValue('--evo-scroll-container-height-offset'), 10);
|
|
208
|
+
const trackAdjust = (!isNaN(trackTop) ? trackTop : 0) + (!isNaN(trackBot) ? trackBot : 0) + (!isNaN(trackOffset) ? trackOffset : 0);
|
|
209
|
+
|
|
210
|
+
const shouldScroll = (containerHeight / scrollHeight) < 1;
|
|
211
|
+
const visibleRatioVert = (containerHeight - trackAdjust) / scrollHeight;
|
|
212
|
+
const thumbHeight = visibleRatioVert * trackHeight;
|
|
213
|
+
|
|
214
|
+
if (this.#scrollbarSettings.thumbHeight != undefined) {
|
|
215
|
+
this.#thumbVert.style.height = `${Math.max(0, Math.min(this.#scrollbarSettings.thumbHeight, trackHeight))}px`;
|
|
216
|
+
} else {
|
|
217
|
+
this.#thumbVert.style.height = `${Math.min(thumbHeight > 20 ? thumbHeight : 20, trackHeight)}px`;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this.#trackVert.style.display = 'block';
|
|
218
221
|
} else {
|
|
219
|
-
this.#trackVert.style.display =
|
|
222
|
+
this.#trackVert.style.display = 'none';
|
|
220
223
|
}
|
|
221
224
|
}
|
|
222
225
|
|
|
223
226
|
if (this.#thumbHorz && this.#trackHorz) {
|
|
224
227
|
const scrollWidth = this.#content.scrollWidth - getPaddingX(this.#content);
|
|
225
228
|
const containerWidth = this.clientWidth - getPaddingX(this);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
this.#
|
|
229
|
+
|
|
230
|
+
if ((containerWidth / scrollWidth) < 1 || this.#scrollbarSettings.trackVisible === true) {
|
|
231
|
+
const trackWidth = this.#trackHorz.clientWidth;
|
|
232
|
+
const trackStyle = getComputedStyle(this.#trackHorz);
|
|
233
|
+
const trackLeft = parseInt(trackStyle.getPropertyValue('--evo-scroll-container-track-horz-left'), 10);
|
|
234
|
+
const trackRight = parseInt(trackStyle.getPropertyValue('--evo-scroll-container-track-horz-right'), 10);
|
|
235
|
+
const trackOffset = parseInt(trackStyle.getPropertyValue('--evo-scroll-container-width-offset'), 10);
|
|
236
|
+
const trackAdjust = (!isNaN(trackLeft) ? trackLeft : 0) + (!isNaN(trackRight) ? trackRight : 0) + (!isNaN(trackOffset) ? trackOffset : 0);
|
|
237
|
+
|
|
238
|
+
const visibleRatioHorz = (containerWidth - trackAdjust) / scrollWidth;
|
|
239
|
+
const thumbWidth = visibleRatioHorz * trackWidth;
|
|
240
|
+
this.#thumbHorz.style.width = `${Math.min(thumbWidth > 20 ? thumbWidth : 20, trackWidth)}px`;
|
|
241
|
+
this.#trackHorz.style.display = 'block';
|
|
238
242
|
} else {
|
|
239
|
-
this.#trackHorz.style.display =
|
|
243
|
+
this.#trackHorz.style.display = 'none';
|
|
240
244
|
}
|
|
241
245
|
}
|
|
242
246
|
}
|