@shower/core 3.4.1 → 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 +22 -15
- package/lib/modules/view.js +2 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core for Shower HTML presentation engine
|
|
3
|
-
* @shower/core v3.4.
|
|
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
|
|
545
|
-
const firstSlide = shower.slides[0];
|
|
546
|
-
if (!firstSlide) return;
|
|
544
|
+
const needsJSScale = !CSS.supports('transform', 'scale(calc(1px / 1px))');
|
|
547
545
|
|
|
548
|
-
|
|
549
|
-
const
|
|
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
|
|
552
|
-
|
|
551
|
+
const updateScale = () => {
|
|
552
|
+
const slideWidth = slideProbe.offsetWidth;
|
|
553
|
+
const slideHeight = slideProbe.offsetHeight;
|
|
554
|
+
if (!slideWidth || !slideHeight) return;
|
|
553
555
|
|
|
554
|
-
|
|
555
|
-
|
|
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) {
|
|
@@ -565,8 +576,6 @@
|
|
|
565
576
|
}
|
|
566
577
|
|
|
567
578
|
requestAnimationFrame(() => {
|
|
568
|
-
updateScale();
|
|
569
|
-
|
|
570
579
|
if (shower.isFullMode) return;
|
|
571
580
|
|
|
572
581
|
const slide = shower.activeSlide;
|
|
@@ -584,8 +593,6 @@
|
|
|
584
593
|
const slide = shower.activeSlide;
|
|
585
594
|
slide.element.scrollIntoView({ block: 'nearest' });
|
|
586
595
|
});
|
|
587
|
-
|
|
588
|
-
window.addEventListener('resize', updateScale);
|
|
589
596
|
};
|
|
590
597
|
|
|
591
598
|
var touch = (shower) => {
|
package/lib/modules/view.js
CHANGED
|
@@ -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,11 +17,9 @@ export default (shower) => {
|
|
|
31
17
|
container.classList.add(listModeClass);
|
|
32
18
|
}
|
|
33
19
|
|
|
34
|
-
|
|
35
|
-
updateScale();
|
|
36
|
-
|
|
37
|
-
if (shower.isFullMode) return;
|
|
20
|
+
if (shower.isFullMode) return;
|
|
38
21
|
|
|
22
|
+
requestAnimationFrame(() => {
|
|
39
23
|
const slide = shower.activeSlide;
|
|
40
24
|
if (slide) {
|
|
41
25
|
slide.element.scrollIntoView({ block: 'center' });
|
|
@@ -51,6 +35,4 @@ export default (shower) => {
|
|
|
51
35
|
const slide = shower.activeSlide;
|
|
52
36
|
slide.element.scrollIntoView({ block: 'nearest' });
|
|
53
37
|
});
|
|
54
|
-
|
|
55
|
-
window.addEventListener('resize', updateScale);
|
|
56
38
|
};
|