@drivexstudio/animations 1.0.2 → 1.0.4
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.cjs +22 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import React4, { useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
5
5
|
|
|
6
6
|
// libs/vendor.js
|
|
7
|
-
import
|
|
7
|
+
import * as gsapModule from "gsap";
|
|
8
8
|
import { useGSAP } from "@gsap/react";
|
|
9
9
|
import { ScrollTrigger } from "gsap/ScrollTrigger";
|
|
10
10
|
import { Flip } from "gsap/Flip";
|
|
@@ -14,7 +14,8 @@ import { InertiaPlugin } from "gsap/InertiaPlugin";
|
|
|
14
14
|
import { Draggable } from "gsap/Draggable";
|
|
15
15
|
import { cx as classVarianceCx } from "class-variance-authority";
|
|
16
16
|
import { cva } from "class-variance-authority";
|
|
17
|
-
gsap.
|
|
17
|
+
var gsap2 = gsapModule.gsap || gsapModule.default || gsapModule;
|
|
18
|
+
gsap2.registerPlugin(
|
|
18
19
|
ScrollTrigger,
|
|
19
20
|
ScrambleTextPlugin,
|
|
20
21
|
SplitText,
|
|
@@ -298,7 +299,7 @@ function ScrambleGroup({
|
|
|
298
299
|
const callbacks = Array.from(childrenMapRef.current.values());
|
|
299
300
|
const staggerValue = customStagger ?? stagger2;
|
|
300
301
|
callbacks.forEach((callbackFn, index) => {
|
|
301
|
-
|
|
302
|
+
gsap2.delayedCall(index * staggerValue, () => {
|
|
302
303
|
callbackFn();
|
|
303
304
|
});
|
|
304
305
|
});
|
|
@@ -307,7 +308,7 @@ function ScrambleGroup({
|
|
|
307
308
|
const setupScrollTrigger = useCallback3(() => {
|
|
308
309
|
if (manual || !containerRef.current) return;
|
|
309
310
|
isTriggering.current = false;
|
|
310
|
-
const tween =
|
|
311
|
+
const tween = gsap2.to(containerRef.current, {
|
|
311
312
|
scrollTrigger: {
|
|
312
313
|
trigger: containerRef.current,
|
|
313
314
|
start,
|
|
@@ -401,7 +402,7 @@ function ScrambleText({
|
|
|
401
402
|
return null;
|
|
402
403
|
}
|
|
403
404
|
killTimeline();
|
|
404
|
-
timelineRef.current =
|
|
405
|
+
timelineRef.current = gsap2.timeline({
|
|
405
406
|
onComplete: () => {
|
|
406
407
|
timelineRef.current = null;
|
|
407
408
|
isCompleteRef.current = true;
|
|
@@ -588,8 +589,8 @@ var AnimatedHeadline = forwardRef(({
|
|
|
588
589
|
useGSAP(() => {
|
|
589
590
|
if (shouldSkip || !containerRef.current || !lines) return;
|
|
590
591
|
const container = containerRef.current;
|
|
591
|
-
|
|
592
|
-
|
|
592
|
+
gsap2.set(container.querySelectorAll("[data-line-inner]"), { opacity: 0 });
|
|
593
|
+
gsap2.set(container.querySelectorAll("[data-brand-rect], [data-fg-rect]"), { scaleX: 0, transformOrigin: "left" });
|
|
593
594
|
}, { dependencies: [shouldSkip, lines] });
|
|
594
595
|
useIdleGSAP(() => {
|
|
595
596
|
if (trigger !== "scroll" || shouldSkip || !lines) return;
|
|
@@ -616,7 +617,7 @@ var AnimatedHeadline = forwardRef(({
|
|
|
616
617
|
const fgRect = lineNode.querySelector("[data-fg-rect]");
|
|
617
618
|
if (!lineInner || !brandRect || !fgRect) continue;
|
|
618
619
|
const rects = [brandRect, fgRect];
|
|
619
|
-
const tl =
|
|
620
|
+
const tl = gsap2.timeline({ delay });
|
|
620
621
|
tl.to(brandRect, { scaleX: 1, duration: 0.45, ease: "power3.inOut" }, 0);
|
|
621
622
|
tl.to(fgRect, { scaleX: 1, duration: 0.45, ease: "power3.inOut" }, 0.1);
|
|
622
623
|
tl.set(lineInner, { opacity: 1 }, 0.5);
|
|
@@ -629,8 +630,8 @@ var AnimatedHeadline = forwardRef(({
|
|
|
629
630
|
hasRevealedRef.current = false;
|
|
630
631
|
if (!containerRef.current) return;
|
|
631
632
|
const container = containerRef.current;
|
|
632
|
-
|
|
633
|
-
|
|
633
|
+
gsap2.set(container.querySelectorAll("[data-line-inner]"), { opacity: 0 });
|
|
634
|
+
gsap2.set(container.querySelectorAll("[data-brand-rect], [data-fg-rect]"), { scaleX: 0, transformOrigin: "left" });
|
|
634
635
|
}, []);
|
|
635
636
|
useImperativeHandle(ref, () => ({ reveal, reset }), [reveal, reset]);
|
|
636
637
|
const resolvedClassName = cx(typographyClasses[displayAs ?? Component], className);
|
|
@@ -752,7 +753,7 @@ function useDualLayerScramble(options) {
|
|
|
752
753
|
const finalWidth = Math.max(((_a = dimensionsRef.current) == null ? void 0 : _a.width) ?? 0, maxWidth);
|
|
753
754
|
const finalHeight = Math.max(((_b = dimensionsRef.current) == null ? void 0 : _b.height) ?? 0, totalHeight);
|
|
754
755
|
isPreparedRef.current = true;
|
|
755
|
-
|
|
756
|
+
gsap2.set(el, { width: finalWidth, height: finalHeight, display: "inline-block", overflow: "hidden" });
|
|
756
757
|
el.innerHTML = "";
|
|
757
758
|
spansRef.current = [];
|
|
758
759
|
linesDataRef.current.forEach((lineData) => {
|
|
@@ -769,7 +770,7 @@ function useDualLayerScramble(options) {
|
|
|
769
770
|
el.appendChild(span);
|
|
770
771
|
spansRef.current.push(span);
|
|
771
772
|
});
|
|
772
|
-
|
|
773
|
+
gsap2.set(el, { opacity: 1 });
|
|
773
774
|
}, []);
|
|
774
775
|
const playScramble = useCallback5((overrides) => {
|
|
775
776
|
var _a;
|
|
@@ -800,7 +801,7 @@ function useDualLayerScramble(options) {
|
|
|
800
801
|
}
|
|
801
802
|
killTimeline();
|
|
802
803
|
isAnimatingRef.current = true;
|
|
803
|
-
timelineRef.current =
|
|
804
|
+
timelineRef.current = gsap2.timeline({
|
|
804
805
|
onComplete: () => {
|
|
805
806
|
var _a2;
|
|
806
807
|
isAnimatingRef.current = false;
|
|
@@ -830,7 +831,7 @@ function useDualLayerScramble(options) {
|
|
|
830
831
|
const nonSpaceCount = originalText.replace(/\s/g, "").length;
|
|
831
832
|
const spacesOnly = originalText.replace(/[^\s]/g, " ");
|
|
832
833
|
(_a2 = timelineRef.current) == null ? void 0 : _a2.add(() => {
|
|
833
|
-
|
|
834
|
+
gsap2.set(span, { opacity: 1 });
|
|
834
835
|
span.innerText = spacesOnly;
|
|
835
836
|
}, delay);
|
|
836
837
|
(_b = timelineRef.current) == null ? void 0 : _b.to(span, {
|
|
@@ -864,7 +865,7 @@ function useDualLayerScramble(options) {
|
|
|
864
865
|
killTimeline();
|
|
865
866
|
if (elementRef.current && isPreparedRef.current) {
|
|
866
867
|
elementRef.current.innerHTML = originalHTMLRef.current || originalTextRef.current;
|
|
867
|
-
|
|
868
|
+
gsap2.set(elementRef.current, {
|
|
868
869
|
opacity: 0,
|
|
869
870
|
width: "auto",
|
|
870
871
|
height: "auto",
|
|
@@ -1368,7 +1369,7 @@ var AnimatedSubtext = forwardRef3(({
|
|
|
1368
1369
|
const lines = splitTextRef.current.lines ?? [];
|
|
1369
1370
|
if (lines.length !== 0) {
|
|
1370
1371
|
elementRef.current.style.visibility = "visible";
|
|
1371
|
-
|
|
1372
|
+
gsap2.fromTo(
|
|
1372
1373
|
lines,
|
|
1373
1374
|
{ y: "100%" },
|
|
1374
1375
|
{
|
|
@@ -1569,7 +1570,7 @@ function Preloader() {
|
|
|
1569
1570
|
requestAnimationFrame(runAnimation);
|
|
1570
1571
|
return;
|
|
1571
1572
|
}
|
|
1572
|
-
timelineRef.current =
|
|
1573
|
+
timelineRef.current = gsap2.timeline();
|
|
1573
1574
|
onReadyRef.current();
|
|
1574
1575
|
squares.forEach((square, index) => {
|
|
1575
1576
|
var _a2;
|
|
@@ -1843,7 +1844,7 @@ export {
|
|
|
1843
1844
|
easingDefinitionToFunction,
|
|
1844
1845
|
getCssScrollLocked,
|
|
1845
1846
|
getLenis,
|
|
1846
|
-
gsap,
|
|
1847
|
+
gsap2 as gsap,
|
|
1847
1848
|
scrollToTop,
|
|
1848
1849
|
setCssScrollLocked,
|
|
1849
1850
|
stagger,
|