@madj2k/fe-frontend-kit 2.0.33 → 2.0.34
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
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @author Steffen Kroggel <developer@steffenkroggel.de>
|
|
13
13
|
* @copyright 2025 Steffen Kroggel
|
|
14
|
-
* @version 1.0.
|
|
14
|
+
* @version 1.0.1
|
|
15
15
|
* @license GNU General Public License v3.0
|
|
16
16
|
* @see https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
17
17
|
*
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* document.querySelectorAll('.js-element-in-viewport').forEach((el) => {
|
|
35
35
|
* new Madj2kElementInViewport(el, {
|
|
36
36
|
* visibleClass: 'is-in-viewport',
|
|
37
|
-
* threshold:
|
|
37
|
+
* threshold: 0.5
|
|
38
38
|
* });
|
|
39
39
|
* });
|
|
40
40
|
*/
|
|
@@ -64,6 +64,17 @@ class Madj2kElementInViewport {
|
|
|
64
64
|
this.element = element;
|
|
65
65
|
this.config = { ...this.config, ...config };
|
|
66
66
|
|
|
67
|
+
const viewportHeight = window.innerHeight;
|
|
68
|
+
const elementHeight = element.offsetHeight;
|
|
69
|
+
|
|
70
|
+
if (elementHeight > viewportHeight) {
|
|
71
|
+
const adjustedThreshold = (viewportHeight * this.config.threshold) / elementHeight;
|
|
72
|
+
this._log(
|
|
73
|
+
`Element taller than viewport. Original threshold ${this.config.threshold} adjusted to ${adjustedThreshold.toFixed(3)}`
|
|
74
|
+
);
|
|
75
|
+
this.config.threshold = Math.min(adjustedThreshold, 1);
|
|
76
|
+
}
|
|
77
|
+
|
|
67
78
|
this._log('Initialized with config:', this.config);
|
|
68
79
|
this._observe();
|
|
69
80
|
}
|