@shower/core 3.4.0 → 3.5.0

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/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Core for Shower HTML presentation engine
3
- * @shower/core v3.3.1, https://github.com/shower/shower/tree/main/packages/core
3
+ * @shower/core v3.4.1, https://github.com/shower/shower/tree/main/packages/core
4
4
  * @copyright 2010–2026 Vadim Makeev, https://pepelsbey.dev
5
5
  * @license MIT
6
6
  */
@@ -541,19 +541,30 @@
541
541
  container.classList.add(listModeClass);
542
542
  }
543
543
 
544
- const updateScale = () => {
545
- const firstSlide = shower.slides[0];
546
- if (!firstSlide) return;
544
+ const needsJSScale = !CSS.supports('transform', 'scale(calc(1px / 1px))');
547
545
 
548
- const { innerWidth, innerHeight } = window;
549
- const { offsetWidth, offsetHeight } = firstSlide.element;
546
+ if (needsJSScale) {
547
+ const slideProbe = document.createElement('div');
548
+ slideProbe.style.cssText = 'position:absolute;visibility:hidden;width:var(--slide-width-px);height:var(--slide-height-px)';
549
+ container.appendChild(slideProbe);
550
550
 
551
- const listScale = 1 / (offsetWidth / innerWidth);
552
- const fullScale = 1 / Math.max(offsetWidth / innerWidth, offsetHeight / innerHeight);
551
+ const updateScale = () => {
552
+ const slideWidth = slideProbe.offsetWidth;
553
+ const slideHeight = slideProbe.offsetHeight;
554
+ if (!slideWidth || !slideHeight) return;
553
555
 
554
- container.style.setProperty('--shower-list-scale', listScale);
555
- container.style.setProperty('--shower-full-scale', fullScale);
556
- };
556
+ const { innerWidth, innerHeight } = window;
557
+
558
+ const listScale = innerWidth / slideWidth;
559
+ const fullScale = Math.min(innerWidth / slideWidth, innerHeight / slideHeight);
560
+
561
+ container.style.setProperty('--shower-list-scale', listScale);
562
+ container.style.setProperty('--shower-full-scale', fullScale);
563
+ };
564
+
565
+ updateScale();
566
+ window.addEventListener('resize', updateScale);
567
+ }
557
568
 
558
569
  const updateModeView = () => {
559
570
  if (shower.isFullMode) {
@@ -564,14 +575,14 @@
564
575
  container.classList.add(listModeClass);
565
576
  }
566
577
 
567
- updateScale();
568
-
569
- if (shower.isFullMode) return;
578
+ requestAnimationFrame(() => {
579
+ if (shower.isFullMode) return;
570
580
 
571
- const slide = shower.activeSlide;
572
- if (slide) {
573
- slide.element.scrollIntoView({ block: 'center' });
574
- }
581
+ const slide = shower.activeSlide;
582
+ if (slide) {
583
+ slide.element.scrollIntoView({ block: 'center' });
584
+ }
585
+ });
575
586
  };
576
587
 
577
588
  shower.addEventListener('start', updateModeView);
@@ -582,8 +593,6 @@
582
593
  const slide = shower.activeSlide;
583
594
  slide.element.scrollIntoView({ block: 'nearest' });
584
595
  });
585
-
586
- window.addEventListener('resize', updateScale);
587
596
  };
588
597
 
589
598
  var touch = (shower) => {
@@ -8,20 +8,6 @@ export default (shower) => {
8
8
  container.classList.add(listModeClass);
9
9
  }
10
10
 
11
- const updateScale = () => {
12
- const firstSlide = shower.slides[0];
13
- if (!firstSlide) return;
14
-
15
- const { innerWidth, innerHeight } = window;
16
- const { offsetWidth, offsetHeight } = firstSlide.element;
17
-
18
- const listScale = 1 / (offsetWidth / innerWidth);
19
- const fullScale = 1 / Math.max(offsetWidth / innerWidth, offsetHeight / innerHeight);
20
-
21
- container.style.setProperty('--shower-list-scale', listScale);
22
- container.style.setProperty('--shower-full-scale', fullScale);
23
- };
24
-
25
11
  const updateModeView = () => {
26
12
  if (shower.isFullMode) {
27
13
  container.classList.remove(listModeClass);
@@ -31,14 +17,14 @@ export default (shower) => {
31
17
  container.classList.add(listModeClass);
32
18
  }
33
19
 
34
- updateScale();
35
-
36
20
  if (shower.isFullMode) return;
37
21
 
38
- const slide = shower.activeSlide;
39
- if (slide) {
40
- slide.element.scrollIntoView({ block: 'center' });
41
- }
22
+ requestAnimationFrame(() => {
23
+ const slide = shower.activeSlide;
24
+ if (slide) {
25
+ slide.element.scrollIntoView({ block: 'center' });
26
+ }
27
+ });
42
28
  };
43
29
 
44
30
  shower.addEventListener('start', updateModeView);
@@ -49,6 +35,4 @@ export default (shower) => {
49
35
  const slide = shower.activeSlide;
50
36
  slide.element.scrollIntoView({ block: 'nearest' });
51
37
  });
52
-
53
- window.addEventListener('resize', updateScale);
54
38
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "name": "@shower/core",
4
4
  "description": "Core for Shower HTML presentation engine",
5
- "version": "3.4.0",
5
+ "version": "3.5.0",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },