@widelab-nc/widelab 1.0.6 → 1.0.7
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 +13 -2
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/src/index.js +68 -21
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -2,10 +2,11 @@ import {initAlpine} from "./init";
|
|
|
2
2
|
import Lenis from '@studio-freight/lenis';
|
|
3
3
|
import gsap from 'gsap';
|
|
4
4
|
import { ScrollTrigger } from "gsap/ScrollTrigger";
|
|
5
|
+
import { ScrollToPlugin } from "gsap/ScrollToPlugin";
|
|
5
6
|
import { CustomEase } from "gsap/CustomEase";
|
|
6
7
|
|
|
7
8
|
// GSAP plugins register and custom easing
|
|
8
|
-
gsap.registerPlugin(ScrollTrigger, CustomEase);
|
|
9
|
+
gsap.registerPlugin(ScrollTrigger, ScrollToPlugin, CustomEase);
|
|
9
10
|
function customGsapEasing() {
|
|
10
11
|
CustomEase.create('loader', '0.83, 0, 0.17, 1');
|
|
11
12
|
CustomEase.create('loader2', '0.77, 0, 0.175, 1');
|
|
@@ -13,13 +14,17 @@ function customGsapEasing() {
|
|
|
13
14
|
|
|
14
15
|
// Functions definitions
|
|
15
16
|
|
|
16
|
-
|
|
17
17
|
//Smooth scroll init
|
|
18
18
|
const lenis = new Lenis({
|
|
19
19
|
duration: 1.2,
|
|
20
20
|
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
|
|
21
21
|
});
|
|
22
22
|
function lenisScroll() {
|
|
23
|
+
lenis.on('scroll', ScrollTrigger.update);
|
|
24
|
+
gsap.ticker.add((time)=>{
|
|
25
|
+
lenis.raf(time * 1000)
|
|
26
|
+
})
|
|
27
|
+
gsap.ticker.lagSmoothing(0)
|
|
23
28
|
function raf(time) {
|
|
24
29
|
lenis.raf(time);
|
|
25
30
|
requestAnimationFrame(raf);
|
|
@@ -49,23 +54,62 @@ function customGsapEasing() {
|
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
|
|
52
|
-
// Reload page on browser back action
|
|
53
|
-
function reloadOnBack() {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
57
|
+
// Reload page on browser back action
|
|
58
|
+
function reloadOnBack() {
|
|
59
|
+
window.addEventListener('pageshow', function (event) {
|
|
60
|
+
if (event.persisted) {
|
|
61
|
+
window.location.reload();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
60
65
|
|
|
61
|
-
// Scroll disable
|
|
62
|
-
function disableScrollMenu() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
66
|
+
// Scroll disable
|
|
67
|
+
function disableScrollMenu() {
|
|
68
|
+
const script = document.createElement('script');
|
|
69
|
+
script.src =
|
|
70
|
+
'https://cdn.jsdelivr.net/npm/@finsweet/attributes-scrolldisable@1/scrolldisable.js';
|
|
71
|
+
script.defer = true;
|
|
72
|
+
document.head.appendChild(script);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Hero move to reveal footer
|
|
76
|
+
function revealFooter() {
|
|
77
|
+
gsap.to('#heroSection', {
|
|
78
|
+
scrollTrigger: {
|
|
79
|
+
trigger: '#bottomWrapper',
|
|
80
|
+
start: 'top bottom',
|
|
81
|
+
toggleActions: 'restart none none reverse',
|
|
82
|
+
},
|
|
83
|
+
y: '-100%',
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Page load animation
|
|
88
|
+
function loadingAnimation() {
|
|
89
|
+
const loaderAnimationIn = gsap.timeline({});
|
|
90
|
+
loaderAnimationIn
|
|
91
|
+
.add(function() {
|
|
92
|
+
history.scrollRestoration = 'manual';
|
|
93
|
+
lenis.scrollTo(0);
|
|
94
|
+
})
|
|
95
|
+
.add(function() {
|
|
96
|
+
lenis.stop();
|
|
97
|
+
});
|
|
98
|
+
loaderAnimationIn.to(
|
|
99
|
+
'.loader_ract',
|
|
100
|
+
{
|
|
101
|
+
delay: 0.2,
|
|
102
|
+
duration: 0.8,
|
|
103
|
+
width: 0,
|
|
104
|
+
ease: 'loader2',
|
|
105
|
+
},
|
|
106
|
+
'>'
|
|
107
|
+
);
|
|
108
|
+
loaderAnimationIn.add(function() {
|
|
109
|
+
lenis.start();
|
|
110
|
+
}, '>');
|
|
111
|
+
loaderAnimationIn.to('.loader_wrapper', { display: 'none', duration: 0.1 }, '>');
|
|
112
|
+
}
|
|
69
113
|
|
|
70
114
|
// Place video inside the text
|
|
71
115
|
window.videoInsideText = function(e) {
|
|
@@ -91,12 +135,15 @@ window.Webflow.push(() => {
|
|
|
91
135
|
console.log('The new code source is loaded!');
|
|
92
136
|
initAlpine();
|
|
93
137
|
lazyLoadVideos();
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
138
|
+
if (Webflow.env("editor") === undefined) {
|
|
139
|
+
lenisScroll();
|
|
140
|
+
}
|
|
97
141
|
customGsapEasing();
|
|
98
142
|
reloadOnBack();
|
|
143
|
+
revealFooter();
|
|
144
|
+
loadingAnimation();
|
|
99
145
|
if (window.innerWidth < 992) {
|
|
100
146
|
disableScrollMenu();
|
|
101
147
|
}
|
|
148
|
+
|
|
102
149
|
});
|