@shower/core 3.5.0 → 3.5.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/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Core for Shower HTML presentation engine
3
- * @shower/core v3.4.1, https://github.com/shower/shower/tree/main/packages/core
3
+ * @shower/core v3.5.2, 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
  */
@@ -350,7 +350,10 @@
350
350
  applyURLSlide();
351
351
  };
352
352
 
353
- applyURL();
353
+ // slide before mode, so full mode finds it instead of defaulting to first
354
+ applyURLSlide();
355
+ applyURLMode();
356
+
354
357
  window.addEventListener('popstate', applyURL);
355
358
 
356
359
  shower.addEventListener('start', () => {
@@ -399,6 +402,8 @@
399
402
  shower.addEventListener('next', (event) => {
400
403
  if (shower.isListMode || event.defaultPrevented || !event.cancelable) return;
401
404
 
405
+ if (activeIndex >= innerSteps.length) return;
406
+
402
407
  activeIndex++;
403
408
  innerSteps.forEach((step, index) => {
404
409
  step.classList.toggle(visitedSlideClass, index < activeIndex);
@@ -541,31 +546,6 @@
541
546
  container.classList.add(listModeClass);
542
547
  }
543
548
 
544
- const needsJSScale = !CSS.supports('transform', 'scale(calc(1px / 1px))');
545
-
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
-
551
- const updateScale = () => {
552
- const slideWidth = slideProbe.offsetWidth;
553
- const slideHeight = slideProbe.offsetHeight;
554
- if (!slideWidth || !slideHeight) return;
555
-
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
- }
568
-
569
549
  const updateModeView = () => {
570
550
  if (shower.isFullMode) {
571
551
  container.classList.remove(listModeClass);
@@ -575,9 +555,9 @@
575
555
  container.classList.add(listModeClass);
576
556
  }
577
557
 
578
- requestAnimationFrame(() => {
579
- if (shower.isFullMode) return;
558
+ if (shower.isFullMode) return;
580
559
 
560
+ requestAnimationFrame(() => {
581
561
  const slide = shower.activeSlide;
582
562
  if (slide) {
583
563
  slide.element.scrollIntoView({ block: 'center' });
@@ -684,11 +664,6 @@
684
664
  view(shower);
685
665
  touch(shower);
686
666
  mouse(shower);
687
-
688
- // maintains invariant: active slide always exists in `full` mode
689
- if (shower.isFullMode && !shower.activeSlide) {
690
- shower.first();
691
- }
692
667
  };
693
668
 
694
669
  class Shower extends EventTarget {
@@ -795,6 +770,10 @@
795
770
  * @emits Shower#modechange
796
771
  */
797
772
  enterFullMode() {
773
+ if (!this.activeSlide) {
774
+ this.first();
775
+ }
776
+
798
777
  this._setMode('full');
799
778
  }
800
779
 
@@ -22,9 +22,4 @@ export default (shower) => {
22
22
  view(shower);
23
23
  touch(shower);
24
24
  mouse(shower);
25
-
26
- // maintains invariant: active slide always exists in `full` mode
27
- if (shower.isFullMode && !shower.activeSlide) {
28
- shower.first();
29
- }
30
25
  };
@@ -33,7 +33,10 @@ export default (shower) => {
33
33
  applyURLSlide();
34
34
  };
35
35
 
36
- applyURL();
36
+ // slide before mode, so full mode finds it instead of defaulting to first
37
+ applyURLSlide();
38
+ applyURLMode();
39
+
37
40
  window.addEventListener('popstate', applyURL);
38
41
 
39
42
  shower.addEventListener('start', () => {
@@ -28,6 +28,8 @@ export default (shower) => {
28
28
  shower.addEventListener('next', (event) => {
29
29
  if (shower.isListMode || event.defaultPrevented || !event.cancelable) return;
30
30
 
31
+ if (activeIndex >= innerSteps.length) return;
32
+
31
33
  activeIndex++;
32
34
  innerSteps.forEach((step, index) => {
33
35
  step.classList.toggle(visitedSlideClass, index < activeIndex);
package/lib/shower.js CHANGED
@@ -107,6 +107,10 @@ class Shower extends EventTarget {
107
107
  * @emits Shower#modechange
108
108
  */
109
109
  enterFullMode() {
110
+ if (!this.activeSlide) {
111
+ this.first();
112
+ }
113
+
110
114
  this._setMode('full');
111
115
  }
112
116
 
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.5.0",
5
+ "version": "3.5.2",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },