@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inizioevoke/astro-core",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -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
- const trackHeight = this.#trackVert.clientHeight;
202
- const trackStyle = getComputedStyle(this.#trackVert);
203
- const trackTop = parseInt(trackStyle.getPropertyValue('--evo-scroll-container-track-vert-top'), 10);
204
- const trackBot = parseInt(trackStyle.getPropertyValue('--evo-scroll-container-track-vert-bottom'), 10);
205
- const trackOffset = parseInt(trackStyle.getPropertyValue('--evo-scroll-container-height-offset'), 10);
206
- const trackAdjust = (!isNaN(trackTop) ? trackTop : 0) + (!isNaN(trackBot) ? trackBot : 0) + (!isNaN(trackOffset) ? trackOffset : 0);
207
-
208
- const visibleRatioVert = (containerHeight - trackAdjust) / scrollHeight;
209
- const thumbHeight = visibleRatioVert * trackHeight;
210
-
211
- if (this.#scrollbarSettings.thumbHeight != undefined) {
212
- this.#thumbVert.style.height = `${Math.max(0, Math.min(this.#scrollbarSettings.thumbHeight, trackHeight))}px`;
213
- } else {
214
- this.#thumbVert.style.height = `${Math.min(thumbHeight > 20 ? thumbHeight : 20, trackHeight)}px`;
215
- }
216
- if (this.#scrollbarSettings.trackVisible !== undefined) {
217
- this.#trackVert.style.display = this.#scrollbarSettings.trackVisible === true ? 'block' : 'none';
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 = visibleRatioVert < 1 ? 'block' : 'none';
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
- const trackWidth = this.#trackHorz.clientWidth;
227
- const trackStyle = getComputedStyle(this.#trackHorz);
228
- const trackLeft = parseInt(trackStyle.getPropertyValue('--evo-scroll-container-track-horz-left'), 10);
229
- const trackRight = parseInt(trackStyle.getPropertyValue('--evo-scroll-container-track-horz-right'), 10);
230
- const trackOffset = parseInt(trackStyle.getPropertyValue('--evo-scroll-container-width-offset'), 10);
231
- const trackAdjust = (!isNaN(trackLeft) ? trackLeft : 0) + (!isNaN(trackRight) ? trackRight : 0) + (!isNaN(trackOffset) ? trackOffset : 0);
232
-
233
- const visibleRatioHorz = (containerWidth - trackAdjust) / scrollWidth;
234
- const thumbWidth = visibleRatioHorz * trackWidth;
235
- this.#thumbHorz.style.width = `${Math.min(thumbWidth > 20 ? thumbWidth : 20, trackWidth)}px`;
236
- if (this.#scrollbarSettings.trackVisible !== undefined) {
237
- this.#trackHorz.style.display = this.#scrollbarSettings.trackVisible === true ? 'block' : 'none';
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 = visibleRatioHorz < 1 ? 'block' : 'none';
243
+ this.#trackHorz.style.display = 'none';
240
244
  }
241
245
  }
242
246
  }