@blackbyte/sugar 1.0.0-beta.25 → 1.0.0-beta.27
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.
|
@@ -2,4 +2,4 @@ import disableTitleTooltips from './disableTitleTooltips.js';
|
|
|
2
2
|
import features from './features.js';
|
|
3
3
|
import scrollClasses from './scrollClasses.js';
|
|
4
4
|
import sectionClasses from './sectionClasses.js';
|
|
5
|
-
export { disableTitleTooltips as __disableTitleTooltips, features as __features, scrollClasses as
|
|
5
|
+
export { disableTitleTooltips as __disableTitleTooltips, features as __features, scrollClasses as __scrollClasses, sectionClasses as __sectionClasses, disableTitleTooltips, features, scrollClasses, sectionClasses, };
|
|
@@ -2,5 +2,5 @@ import disableTitleTooltips from './disableTitleTooltips.js';
|
|
|
2
2
|
import features from './features.js';
|
|
3
3
|
import scrollClasses from './scrollClasses.js';
|
|
4
4
|
import sectionClasses from './sectionClasses.js';
|
|
5
|
-
export { disableTitleTooltips as __disableTitleTooltips, features as __features, scrollClasses as
|
|
5
|
+
export { disableTitleTooltips as __disableTitleTooltips, features as __features, scrollClasses as __scrollClasses, sectionClasses as __sectionClasses, disableTitleTooltips, features, scrollClasses, sectionClasses, };
|
|
6
6
|
//# sourceMappingURL=_exports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_exports.js","sourceRoot":"","sources":["../../../src/js/feature/_exports.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EACL,oBAAoB,IAAI,sBAAsB,EAC9C,QAAQ,IAAI,UAAU,EACtB,aAAa,IAAI,
|
|
1
|
+
{"version":3,"file":"_exports.js","sourceRoot":"","sources":["../../../src/js/feature/_exports.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EACL,oBAAoB,IAAI,sBAAsB,EAC9C,QAAQ,IAAI,UAAU,EACtB,aAAa,IAAI,eAAe,EAChC,cAAc,IAAI,gBAAgB,EAClC,oBAAoB,EACpB,QAAQ,EACR,aAAa,EACb,cAAc,GACf,CAAC"}
|
|
@@ -24,42 +24,25 @@
|
|
|
24
24
|
* @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
|
|
25
25
|
*/
|
|
26
26
|
export default function isInViewport($elm) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
if (top <= 0 &&
|
|
49
|
-
bottom >= containerHeight &&
|
|
50
|
-
right >= containerWidth &&
|
|
51
|
-
isLeftIn) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
if (left <= 0 && right >= containerWidth && top <= 0 && isBottomIn) {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
if (left <= 0 &&
|
|
58
|
-
right >= containerWidth &&
|
|
59
|
-
bottom >= containerHeight &&
|
|
60
|
-
isTopIn) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
27
|
+
// Check if element exists
|
|
28
|
+
if (!$elm)
|
|
29
|
+
return false;
|
|
30
|
+
// Get the bounding rectangle of the element relative to the viewport
|
|
31
|
+
const rect = $elm.getBoundingClientRect();
|
|
32
|
+
// Get viewport dimensions
|
|
33
|
+
const viewportWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
34
|
+
const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
35
|
+
// Check if element has zero dimensions (hidden elements)
|
|
36
|
+
if (rect.width === 0 || rect.height === 0)
|
|
37
|
+
return false;
|
|
38
|
+
// Check if any part of the element is visible in the viewport
|
|
39
|
+
// An element is in viewport if:
|
|
40
|
+
// - Its right edge is to the right of the viewport's left edge (rect.right > 0)
|
|
41
|
+
// - Its left edge is to the left of the viewport's right edge (rect.left < viewportWidth)
|
|
42
|
+
// - Its bottom edge is below the viewport's top edge (rect.bottom > 0)
|
|
43
|
+
// - Its top edge is above the viewport's bottom edge (rect.top < viewportHeight)
|
|
44
|
+
const horizontallyVisible = rect.right > 0 && rect.left < viewportWidth;
|
|
45
|
+
const verticallyVisible = rect.bottom > 0 && rect.top < viewportHeight;
|
|
46
|
+
return horizontallyVisible && verticallyVisible;
|
|
64
47
|
}
|
|
65
48
|
//# sourceMappingURL=isInViewport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInViewport.js","sourceRoot":"","sources":["../../../src/js/is/isInViewport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,IAAiB;IACpD,
|
|
1
|
+
{"version":3,"file":"isInViewport.js","sourceRoot":"","sources":["../../../src/js/is/isInViewport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,IAAiB;IACpD,0BAA0B;IAC1B,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IAExB,qEAAqE;IACrE,MAAM,IAAI,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAE1C,0BAA0B;IAC1B,MAAM,aAAa,GACjB,MAAM,CAAC,UAAU,IAAI,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC;IAC5D,MAAM,cAAc,GAClB,MAAM,CAAC,WAAW,IAAI,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC;IAE9D,yDAAyD;IACzD,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExD,8DAA8D;IAC9D,gCAAgC;IAChC,gFAAgF;IAChF,0FAA0F;IAC1F,uEAAuE;IACvE,iFAAiF;IAEjF,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IACxE,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,GAAG,cAAc,CAAC;IAEvE,OAAO,mBAAmB,IAAI,iBAAiB,CAAC;AAClD,CAAC"}
|