santycss 2.0.1 → 2.2.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/README.md +32 -13
- package/dist/santy-animations.css +179 -1
- package/dist/santy-core.css +33 -4569
- package/dist/santy-scroll.js +45 -0
- package/dist/santy-start.css +9817 -0
- package/dist/santy-variants.css +4579 -0
- package/dist/santy.css +244 -1
- package/dist/santy.min.css +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*! santy-scroll.js — SantyCSS Scroll Observer v2.1
|
|
2
|
+
* Activates when-visible: viewport-entry animations via IntersectionObserver.
|
|
3
|
+
*
|
|
4
|
+
* CDN: <script src="https://cdn.jsdelivr.net/npm/santycss/dist/santy-scroll.js"></script>
|
|
5
|
+
*
|
|
6
|
+
* Modifiers read from element classes:
|
|
7
|
+
* enter-at-{15|25|50|75} — threshold (default: 0.15)
|
|
8
|
+
* enter-repeat — re-trigger on every viewport entry
|
|
9
|
+
*/
|
|
10
|
+
(function () {
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
function getThreshold(el) {
|
|
14
|
+
if (el.classList.contains('enter-at-75')) return 0.75;
|
|
15
|
+
if (el.classList.contains('enter-at-50')) return 0.50;
|
|
16
|
+
if (el.classList.contains('enter-at-25')) return 0.25;
|
|
17
|
+
return 0.15;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function makeObserver(threshold, repeat) {
|
|
21
|
+
return new IntersectionObserver(function (entries) {
|
|
22
|
+
entries.forEach(function (entry) {
|
|
23
|
+
if (entry.isIntersecting) {
|
|
24
|
+
entry.target.classList.add('is-visible');
|
|
25
|
+
if (!repeat) this.unobserve(entry.target);
|
|
26
|
+
} else if (repeat) {
|
|
27
|
+
entry.target.classList.remove('is-visible');
|
|
28
|
+
}
|
|
29
|
+
}.bind(this));
|
|
30
|
+
}, { threshold: threshold });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function init() {
|
|
34
|
+
document.querySelectorAll('[class*="when-visible:"]').forEach(function (el) {
|
|
35
|
+
var obs = makeObserver(getThreshold(el), el.classList.contains('enter-repeat'));
|
|
36
|
+
obs.observe(el);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (document.readyState === 'loading') {
|
|
41
|
+
document.addEventListener('DOMContentLoaded', init);
|
|
42
|
+
} else {
|
|
43
|
+
init();
|
|
44
|
+
}
|
|
45
|
+
}());
|