gsap-react-marquee 0.1.3 → 0.1.5
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/components/gsap-react-marquee.type.d.ts +2 -1
- package/dist/components/gsap-reactmarquee.utils.d.ts +98 -3
- package/dist/index.cjs.css +1 -1
- package/dist/index.cjs.js +1064 -43
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +101 -5
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +1065 -45
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import require$$0, { forwardRef, useRef, useState, useMemo } from 'react';
|
|
1
|
+
import require$$0, { forwardRef, useRef, useState, useLayoutEffect, useMemo } from 'react';
|
|
2
2
|
import { useGSAP } from '@gsap/react';
|
|
3
|
-
import gsap from 'gsap';
|
|
3
|
+
import gsap$1 from 'gsap';
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = {exports: {}};
|
|
6
6
|
|
|
@@ -421,6 +421,710 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
421
421
|
|
|
422
422
|
var jsxRuntimeExports = jsxRuntime.exports;
|
|
423
423
|
|
|
424
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
425
|
+
|
|
426
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
|
|
427
|
+
|
|
428
|
+
/*!
|
|
429
|
+
* Observer 3.13.0
|
|
430
|
+
* https://gsap.com
|
|
431
|
+
*
|
|
432
|
+
* @license Copyright 2008-2025, GreenSock. All rights reserved.
|
|
433
|
+
* Subject to the terms at https://gsap.com/standard-license
|
|
434
|
+
* @author: Jack Doyle, jack@greensock.com
|
|
435
|
+
*/
|
|
436
|
+
|
|
437
|
+
/* eslint-disable */
|
|
438
|
+
var gsap,
|
|
439
|
+
_coreInitted,
|
|
440
|
+
_win,
|
|
441
|
+
_doc,
|
|
442
|
+
_docEl,
|
|
443
|
+
_body,
|
|
444
|
+
_isTouch,
|
|
445
|
+
_pointerType,
|
|
446
|
+
ScrollTrigger,
|
|
447
|
+
_root,
|
|
448
|
+
_normalizer,
|
|
449
|
+
_eventTypes,
|
|
450
|
+
_context,
|
|
451
|
+
_getGSAP = function _getGSAP() {
|
|
452
|
+
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
|
453
|
+
},
|
|
454
|
+
_startup = 1,
|
|
455
|
+
_observers = [],
|
|
456
|
+
_scrollers = [],
|
|
457
|
+
_proxies = [],
|
|
458
|
+
_getTime = Date.now,
|
|
459
|
+
_bridge = function _bridge(name, value) {
|
|
460
|
+
return value;
|
|
461
|
+
},
|
|
462
|
+
_integrate = function _integrate() {
|
|
463
|
+
var core = ScrollTrigger.core,
|
|
464
|
+
data = core.bridge || {},
|
|
465
|
+
scrollers = core._scrollers,
|
|
466
|
+
proxies = core._proxies;
|
|
467
|
+
scrollers.push.apply(scrollers, _scrollers);
|
|
468
|
+
proxies.push.apply(proxies, _proxies);
|
|
469
|
+
_scrollers = scrollers;
|
|
470
|
+
_proxies = proxies;
|
|
471
|
+
|
|
472
|
+
_bridge = function _bridge(name, value) {
|
|
473
|
+
return data[name](value);
|
|
474
|
+
};
|
|
475
|
+
},
|
|
476
|
+
_getProxyProp = function _getProxyProp(element, property) {
|
|
477
|
+
return ~_proxies.indexOf(element) && _proxies[_proxies.indexOf(element) + 1][property];
|
|
478
|
+
},
|
|
479
|
+
_isViewport = function _isViewport(el) {
|
|
480
|
+
return !!~_root.indexOf(el);
|
|
481
|
+
},
|
|
482
|
+
_addListener = function _addListener(element, type, func, passive, capture) {
|
|
483
|
+
return element.addEventListener(type, func, {
|
|
484
|
+
passive: passive !== false,
|
|
485
|
+
capture: !!capture
|
|
486
|
+
});
|
|
487
|
+
},
|
|
488
|
+
_removeListener = function _removeListener(element, type, func, capture) {
|
|
489
|
+
return element.removeEventListener(type, func, !!capture);
|
|
490
|
+
},
|
|
491
|
+
_scrollLeft = "scrollLeft",
|
|
492
|
+
_scrollTop = "scrollTop",
|
|
493
|
+
_onScroll = function _onScroll() {
|
|
494
|
+
return _normalizer && _normalizer.isPressed || _scrollers.cache++;
|
|
495
|
+
},
|
|
496
|
+
_scrollCacheFunc = function _scrollCacheFunc(f, doNotCache) {
|
|
497
|
+
var cachingFunc = function cachingFunc(value) {
|
|
498
|
+
// since reading the scrollTop/scrollLeft/pageOffsetY/pageOffsetX can trigger a layout, this function allows us to cache the value so it only gets read fresh after a "scroll" event fires (or while we're refreshing because that can lengthen the page and alter the scroll position). when "soft" is true, that means don't actually set the scroll, but cache the new value instead (useful in ScrollSmoother)
|
|
499
|
+
if (value || value === 0) {
|
|
500
|
+
_startup && (_win.history.scrollRestoration = "manual"); // otherwise the new position will get overwritten by the browser onload.
|
|
501
|
+
|
|
502
|
+
var isNormalizing = _normalizer && _normalizer.isPressed;
|
|
503
|
+
value = cachingFunc.v = Math.round(value) || (_normalizer && _normalizer.iOS ? 1 : 0); //TODO: iOS Bug: if you allow it to go to 0, Safari can start to report super strange (wildly inaccurate) touch positions!
|
|
504
|
+
|
|
505
|
+
f(value);
|
|
506
|
+
cachingFunc.cacheID = _scrollers.cache;
|
|
507
|
+
isNormalizing && _bridge("ss", value); // set scroll (notify ScrollTrigger so it can dispatch a "scrollStart" event if necessary
|
|
508
|
+
} else if (doNotCache || _scrollers.cache !== cachingFunc.cacheID || _bridge("ref")) {
|
|
509
|
+
cachingFunc.cacheID = _scrollers.cache;
|
|
510
|
+
cachingFunc.v = f();
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
return cachingFunc.v + cachingFunc.offset;
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
cachingFunc.offset = 0;
|
|
517
|
+
return f && cachingFunc;
|
|
518
|
+
},
|
|
519
|
+
_horizontal = {
|
|
520
|
+
s: _scrollLeft,
|
|
521
|
+
p: "left",
|
|
522
|
+
p2: "Left",
|
|
523
|
+
os: "right",
|
|
524
|
+
os2: "Right",
|
|
525
|
+
d: "width",
|
|
526
|
+
d2: "Width",
|
|
527
|
+
a: "x",
|
|
528
|
+
sc: _scrollCacheFunc(function (value) {
|
|
529
|
+
return arguments.length ? _win.scrollTo(value, _vertical.sc()) : _win.pageXOffset || _doc[_scrollLeft] || _docEl[_scrollLeft] || _body[_scrollLeft] || 0;
|
|
530
|
+
})
|
|
531
|
+
},
|
|
532
|
+
_vertical = {
|
|
533
|
+
s: _scrollTop,
|
|
534
|
+
p: "top",
|
|
535
|
+
p2: "Top",
|
|
536
|
+
os: "bottom",
|
|
537
|
+
os2: "Bottom",
|
|
538
|
+
d: "height",
|
|
539
|
+
d2: "Height",
|
|
540
|
+
a: "y",
|
|
541
|
+
op: _horizontal,
|
|
542
|
+
sc: _scrollCacheFunc(function (value) {
|
|
543
|
+
return arguments.length ? _win.scrollTo(_horizontal.sc(), value) : _win.pageYOffset || _doc[_scrollTop] || _docEl[_scrollTop] || _body[_scrollTop] || 0;
|
|
544
|
+
})
|
|
545
|
+
},
|
|
546
|
+
_getTarget = function _getTarget(t, self) {
|
|
547
|
+
return (self && self._ctx && self._ctx.selector || gsap.utils.toArray)(t)[0] || (typeof t === "string" && gsap.config().nullTargetWarn !== false ? console.warn("Element not found:", t) : null);
|
|
548
|
+
},
|
|
549
|
+
_isWithin = function _isWithin(element, list) {
|
|
550
|
+
// check if the element is in the list or is a descendant of an element in the list.
|
|
551
|
+
var i = list.length;
|
|
552
|
+
|
|
553
|
+
while (i--) {
|
|
554
|
+
if (list[i] === element || list[i].contains(element)) {
|
|
555
|
+
return true;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
return false;
|
|
560
|
+
},
|
|
561
|
+
_getScrollFunc = function _getScrollFunc(element, _ref) {
|
|
562
|
+
var s = _ref.s,
|
|
563
|
+
sc = _ref.sc;
|
|
564
|
+
// we store the scroller functions in an alternating sequenced Array like [element, verticalScrollFunc, horizontalScrollFunc, ...] so that we can minimize memory, maximize performance, and we also record the last position as a ".rec" property in order to revert to that after refreshing to ensure things don't shift around.
|
|
565
|
+
_isViewport(element) && (element = _doc.scrollingElement || _docEl);
|
|
566
|
+
|
|
567
|
+
var i = _scrollers.indexOf(element),
|
|
568
|
+
offset = sc === _vertical.sc ? 1 : 2;
|
|
569
|
+
|
|
570
|
+
!~i && (i = _scrollers.push(element) - 1);
|
|
571
|
+
_scrollers[i + offset] || _addListener(element, "scroll", _onScroll); // clear the cache when a scroll occurs
|
|
572
|
+
|
|
573
|
+
var prev = _scrollers[i + offset],
|
|
574
|
+
func = prev || (_scrollers[i + offset] = _scrollCacheFunc(_getProxyProp(element, s), true) || (_isViewport(element) ? sc : _scrollCacheFunc(function (value) {
|
|
575
|
+
return arguments.length ? element[s] = value : element[s];
|
|
576
|
+
})));
|
|
577
|
+
func.target = element;
|
|
578
|
+
prev || (func.smooth = gsap.getProperty(element, "scrollBehavior") === "smooth"); // only set it the first time (don't reset every time a scrollFunc is requested because perhaps it happens during a refresh() when it's disabled in ScrollTrigger.
|
|
579
|
+
|
|
580
|
+
return func;
|
|
581
|
+
},
|
|
582
|
+
_getVelocityProp = function _getVelocityProp(value, minTimeRefresh, useDelta) {
|
|
583
|
+
var v1 = value,
|
|
584
|
+
v2 = value,
|
|
585
|
+
t1 = _getTime(),
|
|
586
|
+
t2 = t1,
|
|
587
|
+
min = minTimeRefresh,
|
|
588
|
+
dropToZeroTime = Math.max(500, min * 3),
|
|
589
|
+
update = function update(value, force) {
|
|
590
|
+
var t = _getTime();
|
|
591
|
+
|
|
592
|
+
if (force || t - t1 > min) {
|
|
593
|
+
v2 = v1;
|
|
594
|
+
v1 = value;
|
|
595
|
+
t2 = t1;
|
|
596
|
+
t1 = t;
|
|
597
|
+
} else {
|
|
598
|
+
v1 += value;
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
reset = function reset() {
|
|
602
|
+
v2 = v1 = 0 ;
|
|
603
|
+
t2 = t1 = 0;
|
|
604
|
+
},
|
|
605
|
+
getVelocity = function getVelocity(latestValue) {
|
|
606
|
+
var tOld = t2,
|
|
607
|
+
vOld = v2,
|
|
608
|
+
t = _getTime();
|
|
609
|
+
|
|
610
|
+
(latestValue || latestValue === 0) && latestValue !== v1 && update(latestValue);
|
|
611
|
+
return t1 === t2 || t - t2 > dropToZeroTime ? 0 : (v1 + (vOld )) / ((t ) - tOld) * 1000;
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
return {
|
|
615
|
+
update: update,
|
|
616
|
+
reset: reset,
|
|
617
|
+
getVelocity: getVelocity
|
|
618
|
+
};
|
|
619
|
+
},
|
|
620
|
+
_getEvent = function _getEvent(e, preventDefault) {
|
|
621
|
+
preventDefault && !e._gsapAllow && e.preventDefault();
|
|
622
|
+
return e.changedTouches ? e.changedTouches[0] : e;
|
|
623
|
+
},
|
|
624
|
+
_getAbsoluteMax = function _getAbsoluteMax(a) {
|
|
625
|
+
var max = Math.max.apply(Math, a),
|
|
626
|
+
min = Math.min.apply(Math, a);
|
|
627
|
+
return Math.abs(max) >= Math.abs(min) ? max : min;
|
|
628
|
+
},
|
|
629
|
+
_setScrollTrigger = function _setScrollTrigger() {
|
|
630
|
+
ScrollTrigger = gsap.core.globals().ScrollTrigger;
|
|
631
|
+
ScrollTrigger && ScrollTrigger.core && _integrate();
|
|
632
|
+
},
|
|
633
|
+
_initCore = function _initCore(core) {
|
|
634
|
+
gsap = core || _getGSAP();
|
|
635
|
+
|
|
636
|
+
if (!_coreInitted && gsap && typeof document !== "undefined" && document.body) {
|
|
637
|
+
_win = window;
|
|
638
|
+
_doc = document;
|
|
639
|
+
_docEl = _doc.documentElement;
|
|
640
|
+
_body = _doc.body;
|
|
641
|
+
_root = [_win, _doc, _docEl, _body];
|
|
642
|
+
gsap.utils.clamp;
|
|
643
|
+
|
|
644
|
+
_context = gsap.core.context || function () {};
|
|
645
|
+
|
|
646
|
+
_pointerType = "onpointerenter" in _body ? "pointer" : "mouse"; // isTouch is 0 if no touch, 1 if ONLY touch, and 2 if it can accommodate touch but also other types like mouse/pointer.
|
|
647
|
+
|
|
648
|
+
_isTouch = Observer.isTouch = _win.matchMedia && _win.matchMedia("(hover: none), (pointer: coarse)").matches ? 1 : "ontouchstart" in _win || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0 ? 2 : 0;
|
|
649
|
+
_eventTypes = Observer.eventTypes = ("ontouchstart" in _docEl ? "touchstart,touchmove,touchcancel,touchend" : !("onpointerdown" in _docEl) ? "mousedown,mousemove,mouseup,mouseup" : "pointerdown,pointermove,pointercancel,pointerup").split(",");
|
|
650
|
+
setTimeout(function () {
|
|
651
|
+
return _startup = 0;
|
|
652
|
+
}, 500);
|
|
653
|
+
|
|
654
|
+
_setScrollTrigger();
|
|
655
|
+
|
|
656
|
+
_coreInitted = 1;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
return _coreInitted;
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
_horizontal.op = _vertical;
|
|
663
|
+
_scrollers.cache = 0;
|
|
664
|
+
var Observer = /*#__PURE__*/function () {
|
|
665
|
+
function Observer(vars) {
|
|
666
|
+
this.init(vars);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
var _proto = Observer.prototype;
|
|
670
|
+
|
|
671
|
+
_proto.init = function init(vars) {
|
|
672
|
+
_coreInitted || _initCore(gsap) || console.warn("Please gsap.registerPlugin(Observer)");
|
|
673
|
+
ScrollTrigger || _setScrollTrigger();
|
|
674
|
+
var tolerance = vars.tolerance,
|
|
675
|
+
dragMinimum = vars.dragMinimum,
|
|
676
|
+
type = vars.type,
|
|
677
|
+
target = vars.target,
|
|
678
|
+
lineHeight = vars.lineHeight,
|
|
679
|
+
debounce = vars.debounce,
|
|
680
|
+
preventDefault = vars.preventDefault,
|
|
681
|
+
onStop = vars.onStop,
|
|
682
|
+
onStopDelay = vars.onStopDelay,
|
|
683
|
+
ignore = vars.ignore,
|
|
684
|
+
wheelSpeed = vars.wheelSpeed,
|
|
685
|
+
event = vars.event,
|
|
686
|
+
onDragStart = vars.onDragStart,
|
|
687
|
+
onDragEnd = vars.onDragEnd,
|
|
688
|
+
onDrag = vars.onDrag,
|
|
689
|
+
onPress = vars.onPress,
|
|
690
|
+
onRelease = vars.onRelease,
|
|
691
|
+
onRight = vars.onRight,
|
|
692
|
+
onLeft = vars.onLeft,
|
|
693
|
+
onUp = vars.onUp,
|
|
694
|
+
onDown = vars.onDown,
|
|
695
|
+
onChangeX = vars.onChangeX,
|
|
696
|
+
onChangeY = vars.onChangeY,
|
|
697
|
+
onChange = vars.onChange,
|
|
698
|
+
onToggleX = vars.onToggleX,
|
|
699
|
+
onToggleY = vars.onToggleY,
|
|
700
|
+
onHover = vars.onHover,
|
|
701
|
+
onHoverEnd = vars.onHoverEnd,
|
|
702
|
+
onMove = vars.onMove,
|
|
703
|
+
ignoreCheck = vars.ignoreCheck,
|
|
704
|
+
isNormalizer = vars.isNormalizer,
|
|
705
|
+
onGestureStart = vars.onGestureStart,
|
|
706
|
+
onGestureEnd = vars.onGestureEnd,
|
|
707
|
+
onWheel = vars.onWheel,
|
|
708
|
+
onEnable = vars.onEnable,
|
|
709
|
+
onDisable = vars.onDisable,
|
|
710
|
+
onClick = vars.onClick,
|
|
711
|
+
scrollSpeed = vars.scrollSpeed,
|
|
712
|
+
capture = vars.capture,
|
|
713
|
+
allowClicks = vars.allowClicks,
|
|
714
|
+
lockAxis = vars.lockAxis,
|
|
715
|
+
onLockAxis = vars.onLockAxis;
|
|
716
|
+
this.target = target = _getTarget(target) || _docEl;
|
|
717
|
+
this.vars = vars;
|
|
718
|
+
ignore && (ignore = gsap.utils.toArray(ignore));
|
|
719
|
+
tolerance = tolerance || 1e-9;
|
|
720
|
+
dragMinimum = dragMinimum || 0;
|
|
721
|
+
wheelSpeed = wheelSpeed || 1;
|
|
722
|
+
scrollSpeed = scrollSpeed || 1;
|
|
723
|
+
type = type || "wheel,touch,pointer";
|
|
724
|
+
debounce = debounce !== false;
|
|
725
|
+
lineHeight || (lineHeight = parseFloat(_win.getComputedStyle(_body).lineHeight) || 22); // note: browser may report "normal", so default to 22.
|
|
726
|
+
|
|
727
|
+
var id,
|
|
728
|
+
onStopDelayedCall,
|
|
729
|
+
dragged,
|
|
730
|
+
moved,
|
|
731
|
+
wheeled,
|
|
732
|
+
locked,
|
|
733
|
+
axis,
|
|
734
|
+
self = this,
|
|
735
|
+
prevDeltaX = 0,
|
|
736
|
+
prevDeltaY = 0,
|
|
737
|
+
passive = vars.passive || !preventDefault && vars.passive !== false,
|
|
738
|
+
scrollFuncX = _getScrollFunc(target, _horizontal),
|
|
739
|
+
scrollFuncY = _getScrollFunc(target, _vertical),
|
|
740
|
+
scrollX = scrollFuncX(),
|
|
741
|
+
scrollY = scrollFuncY(),
|
|
742
|
+
limitToTouch = ~type.indexOf("touch") && !~type.indexOf("pointer") && _eventTypes[0] === "pointerdown",
|
|
743
|
+
// for devices that accommodate mouse events and touch events, we need to distinguish.
|
|
744
|
+
isViewport = _isViewport(target),
|
|
745
|
+
ownerDoc = target.ownerDocument || _doc,
|
|
746
|
+
deltaX = [0, 0, 0],
|
|
747
|
+
// wheel, scroll, pointer/touch
|
|
748
|
+
deltaY = [0, 0, 0],
|
|
749
|
+
onClickTime = 0,
|
|
750
|
+
clickCapture = function clickCapture() {
|
|
751
|
+
return onClickTime = _getTime();
|
|
752
|
+
},
|
|
753
|
+
_ignoreCheck = function _ignoreCheck(e, isPointerOrTouch) {
|
|
754
|
+
return (self.event = e) && ignore && _isWithin(e.target, ignore) || isPointerOrTouch && limitToTouch && e.pointerType !== "touch" || ignoreCheck && ignoreCheck(e, isPointerOrTouch);
|
|
755
|
+
},
|
|
756
|
+
onStopFunc = function onStopFunc() {
|
|
757
|
+
self._vx.reset();
|
|
758
|
+
|
|
759
|
+
self._vy.reset();
|
|
760
|
+
|
|
761
|
+
onStopDelayedCall.pause();
|
|
762
|
+
onStop && onStop(self);
|
|
763
|
+
},
|
|
764
|
+
update = function update() {
|
|
765
|
+
var dx = self.deltaX = _getAbsoluteMax(deltaX),
|
|
766
|
+
dy = self.deltaY = _getAbsoluteMax(deltaY),
|
|
767
|
+
changedX = Math.abs(dx) >= tolerance,
|
|
768
|
+
changedY = Math.abs(dy) >= tolerance;
|
|
769
|
+
|
|
770
|
+
onChange && (changedX || changedY) && onChange(self, dx, dy, deltaX, deltaY); // in ScrollTrigger.normalizeScroll(), we need to know if it was touch/pointer so we need access to the deltaX/deltaY Arrays before we clear them out.
|
|
771
|
+
|
|
772
|
+
if (changedX) {
|
|
773
|
+
onRight && self.deltaX > 0 && onRight(self);
|
|
774
|
+
onLeft && self.deltaX < 0 && onLeft(self);
|
|
775
|
+
onChangeX && onChangeX(self);
|
|
776
|
+
onToggleX && self.deltaX < 0 !== prevDeltaX < 0 && onToggleX(self);
|
|
777
|
+
prevDeltaX = self.deltaX;
|
|
778
|
+
deltaX[0] = deltaX[1] = deltaX[2] = 0;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
if (changedY) {
|
|
782
|
+
onDown && self.deltaY > 0 && onDown(self);
|
|
783
|
+
onUp && self.deltaY < 0 && onUp(self);
|
|
784
|
+
onChangeY && onChangeY(self);
|
|
785
|
+
onToggleY && self.deltaY < 0 !== prevDeltaY < 0 && onToggleY(self);
|
|
786
|
+
prevDeltaY = self.deltaY;
|
|
787
|
+
deltaY[0] = deltaY[1] = deltaY[2] = 0;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
if (moved || dragged) {
|
|
791
|
+
onMove && onMove(self);
|
|
792
|
+
|
|
793
|
+
if (dragged) {
|
|
794
|
+
onDragStart && dragged === 1 && onDragStart(self);
|
|
795
|
+
onDrag && onDrag(self);
|
|
796
|
+
dragged = 0;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
moved = false;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
locked && !(locked = false) && onLockAxis && onLockAxis(self);
|
|
803
|
+
|
|
804
|
+
if (wheeled) {
|
|
805
|
+
onWheel(self);
|
|
806
|
+
wheeled = false;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
id = 0;
|
|
810
|
+
},
|
|
811
|
+
onDelta = function onDelta(x, y, index) {
|
|
812
|
+
deltaX[index] += x;
|
|
813
|
+
deltaY[index] += y;
|
|
814
|
+
|
|
815
|
+
self._vx.update(x);
|
|
816
|
+
|
|
817
|
+
self._vy.update(y);
|
|
818
|
+
|
|
819
|
+
debounce ? id || (id = requestAnimationFrame(update)) : update();
|
|
820
|
+
},
|
|
821
|
+
onTouchOrPointerDelta = function onTouchOrPointerDelta(x, y) {
|
|
822
|
+
if (lockAxis && !axis) {
|
|
823
|
+
self.axis = axis = Math.abs(x) > Math.abs(y) ? "x" : "y";
|
|
824
|
+
locked = true;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
if (axis !== "y") {
|
|
828
|
+
deltaX[2] += x;
|
|
829
|
+
|
|
830
|
+
self._vx.update(x, true); // update the velocity as frequently as possible instead of in the debounced function so that very quick touch-scrolls (flicks) feel natural. If it's the mouse/touch/pointer, force it so that we get snappy/accurate momentum scroll.
|
|
831
|
+
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
if (axis !== "x") {
|
|
835
|
+
deltaY[2] += y;
|
|
836
|
+
|
|
837
|
+
self._vy.update(y, true);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
debounce ? id || (id = requestAnimationFrame(update)) : update();
|
|
841
|
+
},
|
|
842
|
+
_onDrag = function _onDrag(e) {
|
|
843
|
+
if (_ignoreCheck(e, 1)) {
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
e = _getEvent(e, preventDefault);
|
|
848
|
+
var x = e.clientX,
|
|
849
|
+
y = e.clientY,
|
|
850
|
+
dx = x - self.x,
|
|
851
|
+
dy = y - self.y,
|
|
852
|
+
isDragging = self.isDragging;
|
|
853
|
+
self.x = x;
|
|
854
|
+
self.y = y;
|
|
855
|
+
|
|
856
|
+
if (isDragging || (dx || dy) && (Math.abs(self.startX - x) >= dragMinimum || Math.abs(self.startY - y) >= dragMinimum)) {
|
|
857
|
+
dragged = isDragging ? 2 : 1; // dragged: 0 = not dragging, 1 = first drag, 2 = normal drag
|
|
858
|
+
|
|
859
|
+
isDragging || (self.isDragging = true);
|
|
860
|
+
onTouchOrPointerDelta(dx, dy);
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
_onPress = self.onPress = function (e) {
|
|
864
|
+
if (_ignoreCheck(e, 1) || e && e.button) {
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
self.axis = axis = null;
|
|
869
|
+
onStopDelayedCall.pause();
|
|
870
|
+
self.isPressed = true;
|
|
871
|
+
e = _getEvent(e); // note: may need to preventDefault(?) Won't side-scroll on iOS Safari if we do, though.
|
|
872
|
+
|
|
873
|
+
prevDeltaX = prevDeltaY = 0;
|
|
874
|
+
self.startX = self.x = e.clientX;
|
|
875
|
+
self.startY = self.y = e.clientY;
|
|
876
|
+
|
|
877
|
+
self._vx.reset(); // otherwise the t2 may be stale if the user touches and flicks super fast and releases in less than 2 requestAnimationFrame ticks, causing velocity to be 0.
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
self._vy.reset();
|
|
881
|
+
|
|
882
|
+
_addListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, passive, true);
|
|
883
|
+
|
|
884
|
+
self.deltaX = self.deltaY = 0;
|
|
885
|
+
onPress && onPress(self);
|
|
886
|
+
},
|
|
887
|
+
_onRelease = self.onRelease = function (e) {
|
|
888
|
+
if (_ignoreCheck(e, 1)) {
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
_removeListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, true);
|
|
893
|
+
|
|
894
|
+
var isTrackingDrag = !isNaN(self.y - self.startY),
|
|
895
|
+
wasDragging = self.isDragging,
|
|
896
|
+
isDragNotClick = wasDragging && (Math.abs(self.x - self.startX) > 3 || Math.abs(self.y - self.startY) > 3),
|
|
897
|
+
// some touch devices need some wiggle room in terms of sensing clicks - the finger may move a few pixels.
|
|
898
|
+
eventData = _getEvent(e);
|
|
899
|
+
|
|
900
|
+
if (!isDragNotClick && isTrackingDrag) {
|
|
901
|
+
self._vx.reset();
|
|
902
|
+
|
|
903
|
+
self._vy.reset(); //if (preventDefault && allowClicks && self.isPressed) { // check isPressed because in a rare edge case, the inputObserver in ScrollTrigger may stopPropagation() on the press/drag, so the onRelease may get fired without the onPress/onDrag ever getting called, thus it could trigger a click to occur on a link after scroll-dragging it.
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
if (preventDefault && allowClicks) {
|
|
907
|
+
gsap.delayedCall(0.08, function () {
|
|
908
|
+
// some browsers (like Firefox) won't trust script-generated clicks, so if the user tries to click on a video to play it, for example, it simply won't work. Since a regular "click" event will most likely be generated anyway (one that has its isTrusted flag set to true), we must slightly delay our script-generated click so that the "real"/trusted one is prioritized. Remember, when there are duplicate events in quick succession, we suppress all but the first one. Some browsers don't even trigger the "real" one at all, so our synthetic one is a safety valve that ensures that no matter what, a click event does get dispatched.
|
|
909
|
+
if (_getTime() - onClickTime > 300 && !e.defaultPrevented) {
|
|
910
|
+
if (e.target.click) {
|
|
911
|
+
//some browsers (like mobile Safari) don't properly trigger the click event
|
|
912
|
+
e.target.click();
|
|
913
|
+
} else if (ownerDoc.createEvent) {
|
|
914
|
+
var syntheticEvent = ownerDoc.createEvent("MouseEvents");
|
|
915
|
+
syntheticEvent.initMouseEvent("click", true, true, _win, 1, eventData.screenX, eventData.screenY, eventData.clientX, eventData.clientY, false, false, false, false, 0, null);
|
|
916
|
+
e.target.dispatchEvent(syntheticEvent);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
self.isDragging = self.isGesturing = self.isPressed = false;
|
|
924
|
+
onStop && wasDragging && !isNormalizer && onStopDelayedCall.restart(true);
|
|
925
|
+
dragged && update(); // in case debouncing, we don't want onDrag to fire AFTER onDragEnd().
|
|
926
|
+
|
|
927
|
+
onDragEnd && wasDragging && onDragEnd(self);
|
|
928
|
+
onRelease && onRelease(self, isDragNotClick);
|
|
929
|
+
},
|
|
930
|
+
_onGestureStart = function _onGestureStart(e) {
|
|
931
|
+
return e.touches && e.touches.length > 1 && (self.isGesturing = true) && onGestureStart(e, self.isDragging);
|
|
932
|
+
},
|
|
933
|
+
_onGestureEnd = function _onGestureEnd() {
|
|
934
|
+
return (self.isGesturing = false) || onGestureEnd(self);
|
|
935
|
+
},
|
|
936
|
+
onScroll = function onScroll(e) {
|
|
937
|
+
if (_ignoreCheck(e)) {
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
var x = scrollFuncX(),
|
|
942
|
+
y = scrollFuncY();
|
|
943
|
+
onDelta((x - scrollX) * scrollSpeed, (y - scrollY) * scrollSpeed, 1);
|
|
944
|
+
scrollX = x;
|
|
945
|
+
scrollY = y;
|
|
946
|
+
onStop && onStopDelayedCall.restart(true);
|
|
947
|
+
},
|
|
948
|
+
_onWheel = function _onWheel(e) {
|
|
949
|
+
if (_ignoreCheck(e)) {
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
e = _getEvent(e, preventDefault);
|
|
954
|
+
onWheel && (wheeled = true);
|
|
955
|
+
var multiplier = (e.deltaMode === 1 ? lineHeight : e.deltaMode === 2 ? _win.innerHeight : 1) * wheelSpeed;
|
|
956
|
+
onDelta(e.deltaX * multiplier, e.deltaY * multiplier, 0);
|
|
957
|
+
onStop && !isNormalizer && onStopDelayedCall.restart(true);
|
|
958
|
+
},
|
|
959
|
+
_onMove = function _onMove(e) {
|
|
960
|
+
if (_ignoreCheck(e)) {
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
var x = e.clientX,
|
|
965
|
+
y = e.clientY,
|
|
966
|
+
dx = x - self.x,
|
|
967
|
+
dy = y - self.y;
|
|
968
|
+
self.x = x;
|
|
969
|
+
self.y = y;
|
|
970
|
+
moved = true;
|
|
971
|
+
onStop && onStopDelayedCall.restart(true);
|
|
972
|
+
(dx || dy) && onTouchOrPointerDelta(dx, dy);
|
|
973
|
+
},
|
|
974
|
+
_onHover = function _onHover(e) {
|
|
975
|
+
self.event = e;
|
|
976
|
+
onHover(self);
|
|
977
|
+
},
|
|
978
|
+
_onHoverEnd = function _onHoverEnd(e) {
|
|
979
|
+
self.event = e;
|
|
980
|
+
onHoverEnd(self);
|
|
981
|
+
},
|
|
982
|
+
_onClick = function _onClick(e) {
|
|
983
|
+
return _ignoreCheck(e) || _getEvent(e, preventDefault) && onClick(self);
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
onStopDelayedCall = self._dc = gsap.delayedCall(onStopDelay || 0.25, onStopFunc).pause();
|
|
987
|
+
self.deltaX = self.deltaY = 0;
|
|
988
|
+
self._vx = _getVelocityProp(0, 50);
|
|
989
|
+
self._vy = _getVelocityProp(0, 50);
|
|
990
|
+
self.scrollX = scrollFuncX;
|
|
991
|
+
self.scrollY = scrollFuncY;
|
|
992
|
+
self.isDragging = self.isGesturing = self.isPressed = false;
|
|
993
|
+
|
|
994
|
+
_context(this);
|
|
995
|
+
|
|
996
|
+
self.enable = function (e) {
|
|
997
|
+
if (!self.isEnabled) {
|
|
998
|
+
_addListener(isViewport ? ownerDoc : target, "scroll", _onScroll);
|
|
999
|
+
|
|
1000
|
+
type.indexOf("scroll") >= 0 && _addListener(isViewport ? ownerDoc : target, "scroll", onScroll, passive, capture);
|
|
1001
|
+
type.indexOf("wheel") >= 0 && _addListener(target, "wheel", _onWheel, passive, capture);
|
|
1002
|
+
|
|
1003
|
+
if (type.indexOf("touch") >= 0 && _isTouch || type.indexOf("pointer") >= 0) {
|
|
1004
|
+
_addListener(target, _eventTypes[0], _onPress, passive, capture);
|
|
1005
|
+
|
|
1006
|
+
_addListener(ownerDoc, _eventTypes[2], _onRelease);
|
|
1007
|
+
|
|
1008
|
+
_addListener(ownerDoc, _eventTypes[3], _onRelease);
|
|
1009
|
+
|
|
1010
|
+
allowClicks && _addListener(target, "click", clickCapture, true, true);
|
|
1011
|
+
onClick && _addListener(target, "click", _onClick);
|
|
1012
|
+
onGestureStart && _addListener(ownerDoc, "gesturestart", _onGestureStart);
|
|
1013
|
+
onGestureEnd && _addListener(ownerDoc, "gestureend", _onGestureEnd);
|
|
1014
|
+
onHover && _addListener(target, _pointerType + "enter", _onHover);
|
|
1015
|
+
onHoverEnd && _addListener(target, _pointerType + "leave", _onHoverEnd);
|
|
1016
|
+
onMove && _addListener(target, _pointerType + "move", _onMove);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
self.isEnabled = true;
|
|
1020
|
+
self.isDragging = self.isGesturing = self.isPressed = moved = dragged = false;
|
|
1021
|
+
|
|
1022
|
+
self._vx.reset();
|
|
1023
|
+
|
|
1024
|
+
self._vy.reset();
|
|
1025
|
+
|
|
1026
|
+
scrollX = scrollFuncX();
|
|
1027
|
+
scrollY = scrollFuncY();
|
|
1028
|
+
e && e.type && _onPress(e);
|
|
1029
|
+
onEnable && onEnable(self);
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
return self;
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
self.disable = function () {
|
|
1036
|
+
if (self.isEnabled) {
|
|
1037
|
+
// only remove the _onScroll listener if there aren't any others that rely on the functionality.
|
|
1038
|
+
_observers.filter(function (o) {
|
|
1039
|
+
return o !== self && _isViewport(o.target);
|
|
1040
|
+
}).length || _removeListener(isViewport ? ownerDoc : target, "scroll", _onScroll);
|
|
1041
|
+
|
|
1042
|
+
if (self.isPressed) {
|
|
1043
|
+
self._vx.reset();
|
|
1044
|
+
|
|
1045
|
+
self._vy.reset();
|
|
1046
|
+
|
|
1047
|
+
_removeListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, true);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
_removeListener(isViewport ? ownerDoc : target, "scroll", onScroll, capture);
|
|
1051
|
+
|
|
1052
|
+
_removeListener(target, "wheel", _onWheel, capture);
|
|
1053
|
+
|
|
1054
|
+
_removeListener(target, _eventTypes[0], _onPress, capture);
|
|
1055
|
+
|
|
1056
|
+
_removeListener(ownerDoc, _eventTypes[2], _onRelease);
|
|
1057
|
+
|
|
1058
|
+
_removeListener(ownerDoc, _eventTypes[3], _onRelease);
|
|
1059
|
+
|
|
1060
|
+
_removeListener(target, "click", clickCapture, true);
|
|
1061
|
+
|
|
1062
|
+
_removeListener(target, "click", _onClick);
|
|
1063
|
+
|
|
1064
|
+
_removeListener(ownerDoc, "gesturestart", _onGestureStart);
|
|
1065
|
+
|
|
1066
|
+
_removeListener(ownerDoc, "gestureend", _onGestureEnd);
|
|
1067
|
+
|
|
1068
|
+
_removeListener(target, _pointerType + "enter", _onHover);
|
|
1069
|
+
|
|
1070
|
+
_removeListener(target, _pointerType + "leave", _onHoverEnd);
|
|
1071
|
+
|
|
1072
|
+
_removeListener(target, _pointerType + "move", _onMove);
|
|
1073
|
+
|
|
1074
|
+
self.isEnabled = self.isPressed = self.isDragging = false;
|
|
1075
|
+
onDisable && onDisable(self);
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
self.kill = self.revert = function () {
|
|
1080
|
+
self.disable();
|
|
1081
|
+
|
|
1082
|
+
var i = _observers.indexOf(self);
|
|
1083
|
+
|
|
1084
|
+
i >= 0 && _observers.splice(i, 1);
|
|
1085
|
+
_normalizer === self && (_normalizer = 0);
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
_observers.push(self);
|
|
1089
|
+
|
|
1090
|
+
isNormalizer && _isViewport(target) && (_normalizer = self);
|
|
1091
|
+
self.enable(event);
|
|
1092
|
+
};
|
|
1093
|
+
|
|
1094
|
+
_createClass(Observer, [{
|
|
1095
|
+
key: "velocityX",
|
|
1096
|
+
get: function get() {
|
|
1097
|
+
return this._vx.getVelocity();
|
|
1098
|
+
}
|
|
1099
|
+
}, {
|
|
1100
|
+
key: "velocityY",
|
|
1101
|
+
get: function get() {
|
|
1102
|
+
return this._vy.getVelocity();
|
|
1103
|
+
}
|
|
1104
|
+
}]);
|
|
1105
|
+
|
|
1106
|
+
return Observer;
|
|
1107
|
+
}();
|
|
1108
|
+
Observer.version = "3.13.0";
|
|
1109
|
+
|
|
1110
|
+
Observer.create = function (vars) {
|
|
1111
|
+
return new Observer(vars);
|
|
1112
|
+
};
|
|
1113
|
+
|
|
1114
|
+
Observer.register = _initCore;
|
|
1115
|
+
|
|
1116
|
+
Observer.getAll = function () {
|
|
1117
|
+
return _observers.slice();
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
Observer.getById = function (id) {
|
|
1121
|
+
return _observers.filter(function (o) {
|
|
1122
|
+
return o.vars.id === id;
|
|
1123
|
+
})[0];
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
_getGSAP() && gsap.registerPlugin(Observer);
|
|
1127
|
+
|
|
424
1128
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
425
1129
|
|
|
426
1130
|
const CLASS_PART_SEPARATOR = '-';
|
|
@@ -2917,124 +3621,367 @@ const twMerge = /*#__PURE__*/createTailwindMerge(getDefaultConfig);
|
|
|
2917
3621
|
|
|
2918
3622
|
/**
|
|
2919
3623
|
* Utility function to merge Tailwind classes with clsx
|
|
3624
|
+
*
|
|
3625
|
+
* Combines clsx for conditional classes with tailwind-merge to handle
|
|
3626
|
+
* conflicting Tailwind classes by keeping the last occurrence.
|
|
3627
|
+
* This prevents issues like "p-4 p-2" where both would be applied.
|
|
3628
|
+
*
|
|
3629
|
+
* @param inputs - Array of class values (strings, conditionals, objects)
|
|
3630
|
+
* @returns Merged and deduplicated class string
|
|
2920
3631
|
*/
|
|
2921
3632
|
const cn = (...inputs) => {
|
|
2922
3633
|
return twMerge(clsx(inputs));
|
|
2923
3634
|
};
|
|
2924
3635
|
/**
|
|
2925
|
-
*
|
|
3636
|
+
* Traverses the DOM tree upward to find the first non-transparent background color
|
|
3637
|
+
*
|
|
3638
|
+
* This function walks up the element hierarchy starting from the given element,
|
|
3639
|
+
* checking each parent's computed backgroundColor style until it finds a visible
|
|
3640
|
+
* (non-transparent) background color. This is useful for automatically detecting
|
|
3641
|
+
* the effective background behind an element for gradient overlays.
|
|
3642
|
+
*
|
|
3643
|
+
* The traversal stops at the first element with a visible background color,
|
|
3644
|
+
* which could be the element itself or any of its ancestors up to the document root.
|
|
3645
|
+
*
|
|
3646
|
+
* @param el - The HTMLElement to start the background color search from
|
|
3647
|
+
* @returns The first non-transparent background color found in the hierarchy,
|
|
3648
|
+
* or "transparent" if no visible background is found
|
|
3649
|
+
*
|
|
3650
|
+
* @example
|
|
3651
|
+
* // Element with white parent background
|
|
3652
|
+
* const color = getEffectiveBackgroundColor(marqueeElement);
|
|
3653
|
+
* // Returns: "rgb(255, 255, 255)" or "#ffffff"
|
|
3654
|
+
*
|
|
3655
|
+
* @example
|
|
3656
|
+
* // Element with no background set anywhere in hierarchy
|
|
3657
|
+
* const color = getEffectiveBackgroundColor(marqueeElement);
|
|
3658
|
+
* // Returns: "transparent"
|
|
3659
|
+
*/
|
|
3660
|
+
const getEffectiveBackgroundColor = (el) => {
|
|
3661
|
+
let current = el;
|
|
3662
|
+
while (current) {
|
|
3663
|
+
const bg = window.getComputedStyle(current).backgroundColor;
|
|
3664
|
+
// Check if background color is visible (not transparent or rgba(0,0,0,0))
|
|
3665
|
+
if (bg && bg !== "rgba(0, 0, 0, 0)" && bg !== "transparent") {
|
|
3666
|
+
return bg;
|
|
3667
|
+
}
|
|
3668
|
+
current = current.parentElement;
|
|
3669
|
+
}
|
|
3670
|
+
return "transparent"; // fallback when no visible background is found
|
|
3671
|
+
};
|
|
3672
|
+
/**
|
|
3673
|
+
* Sets up container styles and rotation handling for the marquee
|
|
3674
|
+
*
|
|
3675
|
+
* This function handles the complex styling requirements for different marquee orientations:
|
|
3676
|
+
*
|
|
3677
|
+
* 1. **Basic Setup**: Applies gap spacing and rotation for vertical marquees
|
|
3678
|
+
* 2. **Vertical Mode**: Rotates container 90° and adjusts width to parent height
|
|
3679
|
+
* 3. **Rotation Alignment**: Special mode for vertical text that remains readable
|
|
3680
|
+
*
|
|
3681
|
+
* @param containerMarquee - The main container element that holds all marquee instances
|
|
3682
|
+
* @param marquees - Array of individual marquee wrapper elements
|
|
3683
|
+
* @param marqueesChildren - Array of content container elements within each marquee
|
|
3684
|
+
* @param isVertical - Boolean indicating if marquee moves up/down instead of left/right
|
|
3685
|
+
* @param props - Configuration object containing spacing and alignment options
|
|
2926
3686
|
*/
|
|
2927
3687
|
const setupContainerStyles = (containerMarquee, marquees, marqueesChildren, isVertical, props) => {
|
|
2928
3688
|
const { spacing = 16, alignRotationWithY = false } = props;
|
|
2929
|
-
|
|
3689
|
+
/**
|
|
3690
|
+
* Apply base container styling
|
|
3691
|
+
* - gap: Space between marquee elements (prevents content overlap)
|
|
3692
|
+
* - rotate: 90° rotation for vertical movement (transforms horizontal motion to vertical)
|
|
3693
|
+
*/
|
|
3694
|
+
gsap$1.set(containerMarquee, {
|
|
2930
3695
|
gap: `${spacing}px`,
|
|
2931
3696
|
rotate: isVertical ? 90 : "0",
|
|
2932
3697
|
});
|
|
3698
|
+
/**
|
|
3699
|
+
* Handle vertical marquee specific adjustments
|
|
3700
|
+
* When isVertical is true, the container is rotated 90°, so we need to:
|
|
3701
|
+
* 1. Set container width to match parent height (since it's rotated)
|
|
3702
|
+
* 2. Allow content to overflow visible bounds for smooth transitions
|
|
3703
|
+
*/
|
|
2933
3704
|
if (isVertical) {
|
|
2934
3705
|
const parent = containerMarquee.parentNode;
|
|
2935
|
-
gsap.set(containerMarquee, {
|
|
2936
|
-
width: parent.offsetHeight,
|
|
3706
|
+
gsap$1.set(containerMarquee, {
|
|
3707
|
+
width: parent.offsetHeight, // Width becomes the vertical space available
|
|
2937
3708
|
});
|
|
2938
|
-
gsap.set(marqueesChildren, {
|
|
2939
|
-
overflow: "visible",
|
|
3709
|
+
gsap$1.set(marqueesChildren, {
|
|
3710
|
+
overflow: "visible", // Prevents clipping during animation
|
|
2940
3711
|
});
|
|
2941
3712
|
}
|
|
3713
|
+
/**
|
|
3714
|
+
* Handle special rotation alignment mode
|
|
3715
|
+
*
|
|
3716
|
+
* This creates a complex layout where:
|
|
3717
|
+
* - The main container is rotated for vertical movement
|
|
3718
|
+
* - Individual content is counter-rotated to remain readable
|
|
3719
|
+
* - Content is repositioned to align properly within the rotated space
|
|
3720
|
+
*
|
|
3721
|
+
* Use case: Vertical text marquee where text remains horizontally readable
|
|
3722
|
+
*/
|
|
2942
3723
|
if (alignRotationWithY && marquees.length > 0) {
|
|
2943
3724
|
const marqueeHeight = marquees[0].offsetHeight;
|
|
2944
|
-
|
|
3725
|
+
// Center align items within the container
|
|
3726
|
+
gsap$1.set(containerMarquee, {
|
|
2945
3727
|
alignItems: "center",
|
|
2946
3728
|
});
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
3729
|
+
/**
|
|
3730
|
+
* Counter-rotate content and reposition for proper alignment
|
|
3731
|
+
*
|
|
3732
|
+
* - rotate: -90° counters the container's 90° rotation
|
|
3733
|
+
* - x: Horizontal offset to center content within rotated container
|
|
3734
|
+
* - width: Set to marquee height since dimensions are swapped after rotation
|
|
3735
|
+
* - flexWrap/wordBreak/whiteSpace: Handle text flow in constrained space
|
|
3736
|
+
*/
|
|
3737
|
+
gsap$1.set(marqueesChildren, {
|
|
3738
|
+
rotate: -90, // Counter-rotate to keep text readable
|
|
3739
|
+
x: (containerMarquee.offsetWidth - spacing) / 2 - spacing, // Center horizontally
|
|
2950
3740
|
display: "flex",
|
|
2951
|
-
flexWrap: "wrap",
|
|
2952
|
-
width: marqueeHeight,
|
|
2953
|
-
wordBreak: "break-all",
|
|
2954
|
-
whiteSpace: "break-spaces",
|
|
3741
|
+
flexWrap: "wrap", // Allow text to wrap within constrained width
|
|
3742
|
+
width: marqueeHeight, // Width constraint for wrapped text
|
|
3743
|
+
wordBreak: "break-all", // Force word breaking if necessary
|
|
3744
|
+
whiteSpace: "break-spaces", // Preserve spaces while allowing breaks
|
|
2955
3745
|
});
|
|
2956
|
-
|
|
3746
|
+
/**
|
|
3747
|
+
* Adjust marquee height to fit within the rotated container
|
|
3748
|
+
* Accounts for spacing to prevent overflow
|
|
3749
|
+
*/
|
|
3750
|
+
gsap$1.set(marquees, {
|
|
2957
3751
|
height: containerMarquee.offsetWidth - spacing,
|
|
2958
3752
|
});
|
|
2959
3753
|
}
|
|
2960
3754
|
};
|
|
2961
3755
|
/**
|
|
2962
|
-
* Calculates the number of duplicates needed
|
|
3756
|
+
* Calculates the number of content duplicates needed for seamless looping
|
|
3757
|
+
*
|
|
3758
|
+
* For smooth infinite scrolling, we need enough content copies to fill the visible area
|
|
3759
|
+
* plus buffer space. This prevents gaps when content loops back to the beginning.
|
|
3760
|
+
*
|
|
3761
|
+
* Algorithm:
|
|
3762
|
+
* 1. If not in fill mode, only one copy is needed (content already spans container)
|
|
3763
|
+
* 2. Determine target width (viewport height for vertical, container width for horizontal)
|
|
3764
|
+
* 3. Calculate how many copies fit in the target space, rounding up for complete coverage
|
|
3765
|
+
*
|
|
3766
|
+
* @param marqueeChildrenWidth - Width of a single content instance
|
|
3767
|
+
* @param containerMarqueeWidth - Width of the marquee container
|
|
3768
|
+
* @param isVertical - Whether the marquee scrolls vertically
|
|
3769
|
+
* @param props - Configuration object containing fill mode setting
|
|
3770
|
+
* @returns Number of content duplicates needed (minimum 1)
|
|
2963
3771
|
*/
|
|
2964
3772
|
const calculateDuplicates = (marqueeChildrenWidth, containerMarqueeWidth, isVertical, props) => {
|
|
3773
|
+
// If not filling, content presumably already spans the container
|
|
2965
3774
|
if (!props.fill)
|
|
2966
3775
|
return 1;
|
|
3776
|
+
/**
|
|
3777
|
+
* Determine the space we need to fill
|
|
3778
|
+
* - Vertical: Use viewport height (since container is rotated 90°)
|
|
3779
|
+
* - Horizontal: Use container width
|
|
3780
|
+
*/
|
|
2967
3781
|
const targetWidth = isVertical ? window.innerHeight : containerMarqueeWidth;
|
|
3782
|
+
/**
|
|
3783
|
+
* Calculate required duplicates
|
|
3784
|
+
* Math.ceil ensures we have enough copies to fully cover the target width
|
|
3785
|
+
* Even if the last copy is partially visible, it prevents gaps during looping
|
|
3786
|
+
*/
|
|
2968
3787
|
return marqueeChildrenWidth < targetWidth
|
|
2969
3788
|
? Math.ceil(targetWidth / marqueeChildrenWidth)
|
|
2970
|
-
: 1;
|
|
3789
|
+
: 1; // If content is already larger than target, one copy suffices
|
|
2971
3790
|
};
|
|
2972
3791
|
/**
|
|
2973
|
-
* Determines the minimum width for marquee elements
|
|
3792
|
+
* Determines the minimum width for marquee elements based on content and container
|
|
3793
|
+
*
|
|
3794
|
+
* This function ensures marquee elements have appropriate dimensions for their content
|
|
3795
|
+
* and container context, handling different modes and orientations.
|
|
3796
|
+
*
|
|
3797
|
+
* Width determination logic:
|
|
3798
|
+
* 1. **Fill mode**: Auto width lets content size naturally
|
|
3799
|
+
* 2. **Rotation alignment**: Use content height as width (rotated dimensions)
|
|
3800
|
+
* 3. **Undersized content**: Stretch to 100% to fill container
|
|
3801
|
+
* 4. **Oversized content**: Use actual content width for overflow scrolling
|
|
3802
|
+
*
|
|
3803
|
+
* @param marqueesChildren - Array of content elements for dimension measurement
|
|
3804
|
+
* @param totalWidth - Combined width of all content elements
|
|
3805
|
+
* @param containerMarqueeWidth - Available container width
|
|
3806
|
+
* @param props - Configuration object containing fill and alignment settings
|
|
3807
|
+
* @returns CSS width value (string with units or number for pixels)
|
|
2974
3808
|
*/
|
|
2975
3809
|
const getMinWidth = (marqueesChildren, totalWidth, containerMarqueeWidth, props) => {
|
|
2976
3810
|
const { fill = false, alignRotationWithY = false } = props;
|
|
3811
|
+
// Fill mode: Let content size itself naturally
|
|
2977
3812
|
if (fill)
|
|
2978
3813
|
return "auto";
|
|
3814
|
+
/**
|
|
3815
|
+
* Rotation alignment mode: Use height as width
|
|
3816
|
+
* Since content is rotated 90°, height becomes the effective width
|
|
3817
|
+
*/
|
|
2979
3818
|
if (alignRotationWithY && marqueesChildren.length > 0) {
|
|
2980
3819
|
return `${marqueesChildren[0].offsetHeight}px`;
|
|
2981
3820
|
}
|
|
3821
|
+
/**
|
|
3822
|
+
* Content smaller than container: Stretch to fill
|
|
3823
|
+
* Prevents awkward gaps in the marquee display
|
|
3824
|
+
*/
|
|
2982
3825
|
if (totalWidth < containerMarqueeWidth)
|
|
2983
3826
|
return "100%";
|
|
3827
|
+
/**
|
|
3828
|
+
* Content larger than container: Use actual content width
|
|
3829
|
+
* Allows content to overflow and scroll properly
|
|
3830
|
+
*/
|
|
2984
3831
|
return `${totalWidth}px`;
|
|
2985
3832
|
};
|
|
2986
3833
|
/**
|
|
2987
3834
|
* Creates a complex fill-based marquee animation with seamless looping
|
|
3835
|
+
*
|
|
3836
|
+
* This is the core animation engine that creates smooth, continuous scrolling.
|
|
3837
|
+
* It handles the complex math required for seamless looping by calculating
|
|
3838
|
+
* precise positions and durations for each content element.
|
|
3839
|
+
*
|
|
3840
|
+
* Animation Strategy:
|
|
3841
|
+
* 1. **Position Calculation**: Convert pixel positions to percentages for responsive scaling
|
|
3842
|
+
* 2. **Seamless Looping**: Calculate track length and loop points to prevent gaps
|
|
3843
|
+
* 3. **Staggered Animation**: Each element starts at different times for smooth flow
|
|
3844
|
+
* 4. **Direction Handling**: Support forward and reverse directions with proper timing
|
|
3845
|
+
*
|
|
3846
|
+
* Technical Details:
|
|
3847
|
+
* - Uses xPercent for percentage-based positioning (responsive to element width changes)
|
|
3848
|
+
* - Creates two-part animation: main movement + seamless loop reset
|
|
3849
|
+
* - Calculates precise durations based on distance and speed for consistent motion
|
|
3850
|
+
*
|
|
3851
|
+
* @param elementsToAnimate - Array of DOM elements to animate (content or containers)
|
|
3852
|
+
* @param startX - Starting X position reference point
|
|
3853
|
+
* @param tl - GSAP timeline to add animations to
|
|
3854
|
+
* @param isReverse - Whether animation should play in reverse direction
|
|
3855
|
+
* @param props - Configuration object with spacing, speed, delay, and other settings
|
|
2988
3856
|
*/
|
|
2989
3857
|
const coreAnimation = (elementsToAnimate, startX, tl, isReverse, props) => {
|
|
2990
3858
|
const { spacing = 16, speed = 100, delay = 0, paused = false, alignRotationWithY = false, } = props;
|
|
2991
|
-
|
|
2992
|
-
const
|
|
2993
|
-
const
|
|
2994
|
-
|
|
2995
|
-
|
|
3859
|
+
// Arrays to store calculated values for each element
|
|
3860
|
+
const widths = []; // Element widths in pixels
|
|
3861
|
+
const xPercents = []; // Current positions as percentages
|
|
3862
|
+
const latestPos = elementsToAnimate.length - 1; // Index of last element
|
|
3863
|
+
/**
|
|
3864
|
+
* Initialize positions and calculate percentage values
|
|
3865
|
+
*
|
|
3866
|
+
* GSAP's xPercent property positions elements relative to their own width:
|
|
3867
|
+
* - 0% = element's left edge at current x position
|
|
3868
|
+
* - -100% = element's right edge at current x position
|
|
3869
|
+
* - 100% = element positioned one full width to the right
|
|
3870
|
+
*
|
|
3871
|
+
* This approach makes animations responsive to width changes
|
|
3872
|
+
*/
|
|
3873
|
+
gsap$1.set(elementsToAnimate, {
|
|
2996
3874
|
xPercent: (i, el) => {
|
|
2997
|
-
|
|
3875
|
+
// Get element width and store for later calculations
|
|
3876
|
+
const w = (widths[i] = parseFloat(String(gsap$1.getProperty(el, "width", "px"))));
|
|
3877
|
+
/**
|
|
3878
|
+
* Calculate current position as percentage of element width
|
|
3879
|
+
* Combines pixel position with any existing percentage offset
|
|
3880
|
+
*/
|
|
2998
3881
|
xPercents[i] =
|
|
2999
|
-
(parseFloat(String(gsap.getProperty(el, "x", "px"))) / w) * 100 +
|
|
3000
|
-
Number(gsap.getProperty(el, "xPercent"));
|
|
3882
|
+
(parseFloat(String(gsap$1.getProperty(el, "x", "px"))) / w) * 100 +
|
|
3883
|
+
Number(gsap$1.getProperty(el, "xPercent"));
|
|
3001
3884
|
return xPercents[i];
|
|
3002
3885
|
},
|
|
3003
3886
|
});
|
|
3004
|
-
|
|
3005
|
-
|
|
3887
|
+
// Reset x position to 0 since we're now using xPercent for positioning
|
|
3888
|
+
gsap$1.set(elementsToAnimate, { x: 0 });
|
|
3889
|
+
/**
|
|
3890
|
+
* Calculate total track length for seamless looping
|
|
3891
|
+
*
|
|
3892
|
+
* Track length is the total distance content travels before looping back.
|
|
3893
|
+
* It includes:
|
|
3894
|
+
* - Distance from start to last element's left edge
|
|
3895
|
+
* - Last element's offset percentage in pixels
|
|
3896
|
+
* - Last element's full width
|
|
3897
|
+
* - Spacing gap after last element
|
|
3898
|
+
*
|
|
3899
|
+
* This ensures smooth transitions when content loops back to beginning
|
|
3900
|
+
*/
|
|
3006
3901
|
const trackLength = elementsToAnimate[latestPos].offsetLeft +
|
|
3007
3902
|
(xPercents[latestPos] / 100) * widths[latestPos] -
|
|
3008
3903
|
startX +
|
|
3009
3904
|
elementsToAnimate[latestPos].offsetWidth +
|
|
3010
3905
|
spacing;
|
|
3011
|
-
|
|
3906
|
+
/**
|
|
3907
|
+
* Create staggered animation for each element
|
|
3908
|
+
*
|
|
3909
|
+
* Each element gets a two-part animation:
|
|
3910
|
+
* 1. Main movement: From start position to loop point
|
|
3911
|
+
* 2. Reset movement: From end of track back to start (seamless loop)
|
|
3912
|
+
*/
|
|
3012
3913
|
elementsToAnimate.forEach((item, i) => {
|
|
3914
|
+
// Current position in pixels
|
|
3013
3915
|
const curX = (xPercents[i] / 100) * widths[i];
|
|
3916
|
+
// Distance from element to animation start point
|
|
3014
3917
|
const distanceToStart = item.offsetLeft + curX - startX;
|
|
3918
|
+
/**
|
|
3919
|
+
* Calculate distance to complete loop point
|
|
3920
|
+
*
|
|
3921
|
+
* For rotation alignment mode, use height instead of width
|
|
3922
|
+
* since the element dimensions are effectively swapped
|
|
3923
|
+
*/
|
|
3015
3924
|
const distanceToLoop = alignRotationWithY
|
|
3016
3925
|
? distanceToStart + item.offsetHeight - spacing
|
|
3017
3926
|
: distanceToStart + widths[i];
|
|
3927
|
+
/**
|
|
3928
|
+
* Part 1: Main animation - move from current position to loop point
|
|
3929
|
+
*
|
|
3930
|
+
* - Target: Position where element should loop back
|
|
3931
|
+
* - Duration: Based on distance and speed for consistent motion
|
|
3932
|
+
* - Start time: 0 (all elements start simultaneously but from different positions)
|
|
3933
|
+
*/
|
|
3018
3934
|
tl.to(item, {
|
|
3019
3935
|
xPercent: ((curX - distanceToLoop) / widths[i]) * 100,
|
|
3020
3936
|
duration: distanceToLoop / speed,
|
|
3021
|
-
}, 0
|
|
3937
|
+
}, 0 // Start immediately
|
|
3938
|
+
).fromTo(item, {
|
|
3939
|
+
/**
|
|
3940
|
+
* Part 2 Start: Position element at end of track
|
|
3941
|
+
* This creates the illusion of seamless continuation
|
|
3942
|
+
*/
|
|
3022
3943
|
xPercent: ((curX - distanceToLoop + trackLength) / widths[i]) * 100,
|
|
3023
3944
|
}, {
|
|
3945
|
+
/**
|
|
3946
|
+
* Part 2 End: Move back to original start position
|
|
3947
|
+
* Completes the seamless loop cycle
|
|
3948
|
+
*/
|
|
3024
3949
|
xPercent: xPercents[i],
|
|
3025
3950
|
duration: (curX - distanceToLoop + trackLength - curX) / speed,
|
|
3026
|
-
immediateRender: false,
|
|
3027
|
-
}, distanceToLoop / speed
|
|
3951
|
+
immediateRender: false, // Don't render start position immediately
|
|
3952
|
+
}, distanceToLoop / speed // Start after main animation completes
|
|
3953
|
+
);
|
|
3028
3954
|
});
|
|
3955
|
+
// Apply initial delay before starting animations
|
|
3029
3956
|
tl.delay(delay);
|
|
3957
|
+
/**
|
|
3958
|
+
* Handle reverse direction animations
|
|
3959
|
+
*
|
|
3960
|
+
* For reverse marquees (right/down directions):
|
|
3961
|
+
* 1. Set timeline to end position
|
|
3962
|
+
* 2. Pause to prevent immediate playback
|
|
3963
|
+
* 3. Use delayed call to start reverse playback after initial delay
|
|
3964
|
+
* 4. Set up reverse completion handler for continuous looping
|
|
3965
|
+
*/
|
|
3030
3966
|
if (isReverse) {
|
|
3967
|
+
// If paused is requested, just pause and return
|
|
3031
3968
|
if (paused) {
|
|
3032
3969
|
tl.pause();
|
|
3033
3970
|
return;
|
|
3034
3971
|
}
|
|
3972
|
+
// Position timeline at end and pause
|
|
3035
3973
|
tl.progress(1).pause();
|
|
3036
|
-
|
|
3037
|
-
|
|
3974
|
+
/**
|
|
3975
|
+
* Start reverse playback after delay
|
|
3976
|
+
* This creates the proper reverse scrolling effect
|
|
3977
|
+
*/
|
|
3978
|
+
gsap$1.delayedCall(delay, () => {
|
|
3979
|
+
tl.reverse(); // Start playing backwards
|
|
3980
|
+
/**
|
|
3981
|
+
* Handle seamless looping in reverse direction
|
|
3982
|
+
* When reverse completes, restart from end position
|
|
3983
|
+
* This prevents new delay in continuous reverse scrolling
|
|
3984
|
+
*/
|
|
3038
3985
|
tl.eventCallback("onReverseComplete", () => {
|
|
3039
3986
|
tl.totalTime(tl.rawTime() + tl.duration() * 100);
|
|
3040
3987
|
});
|
|
@@ -3043,23 +3990,30 @@ const coreAnimation = (elementsToAnimate, startX, tl, isReverse, props) => {
|
|
|
3043
3990
|
};
|
|
3044
3991
|
|
|
3045
3992
|
const GSAPReactMarquee = forwardRef((props, ref) => {
|
|
3046
|
-
const { children, className, dir = "left", loop = -1, paused = false, fill = false, } = props;
|
|
3993
|
+
const { children, className, dir = "left", loop = -1, paused = false, fill = false, followScrollDir = false, scrollSpeed = 2.5, gradient = false, gradientColor = null, } = props;
|
|
3047
3994
|
const rootRef = useRef(null) || ref;
|
|
3048
3995
|
const containerRef = rootRef;
|
|
3049
3996
|
const marqueeRef = useRef(null);
|
|
3050
3997
|
const [marqueeDuplicates, setMarqueeDuplicates] = useState(1);
|
|
3998
|
+
const [effectivelyGradient, setEffectivelyGradient] = useState(null);
|
|
3999
|
+
useLayoutEffect(() => {
|
|
4000
|
+
if (!gradient || !(containerRef === null || containerRef === void 0 ? void 0 : containerRef.current))
|
|
4001
|
+
return;
|
|
4002
|
+
const effectiveBg = getEffectiveBackgroundColor(containerRef.current);
|
|
4003
|
+
setEffectivelyGradient(effectiveBg);
|
|
4004
|
+
}, [gradient]);
|
|
3051
4005
|
const isVertical = dir === "up" || dir === "down";
|
|
3052
4006
|
const isReverse = dir === "down" || dir === "right";
|
|
3053
4007
|
useGSAP(() => {
|
|
3054
4008
|
if (!(marqueeRef === null || marqueeRef === void 0 ? void 0 : marqueeRef.current) || !containerRef.current)
|
|
3055
4009
|
return;
|
|
3056
4010
|
const containerMarquee = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
3057
|
-
const marquees = gsap.utils.toArray(containerMarquee.querySelectorAll(".gsap-react-marquee"));
|
|
3058
|
-
const marqueesChildren = gsap.utils.toArray(containerMarquee.querySelectorAll(".gsap-react-marquee .gsap-react-marquee-content"));
|
|
4011
|
+
const marquees = gsap$1.utils.toArray(containerMarquee.querySelectorAll(".gsap-react-marquee"));
|
|
4012
|
+
const marqueesChildren = gsap$1.utils.toArray(containerMarquee.querySelectorAll(".gsap-react-marquee .gsap-react-marquee-content"));
|
|
3059
4013
|
const marquee = marqueeRef.current;
|
|
3060
4014
|
if (!marquee || !marqueesChildren)
|
|
3061
4015
|
return;
|
|
3062
|
-
const tl = gsap.timeline({
|
|
4016
|
+
const tl = gsap$1.timeline({
|
|
3063
4017
|
paused: paused,
|
|
3064
4018
|
repeat: loop,
|
|
3065
4019
|
defaults: { ease: "none" },
|
|
@@ -3072,32 +4026,98 @@ const GSAPReactMarquee = forwardRef((props, ref) => {
|
|
|
3072
4026
|
setupContainerStyles(containerMarquee, marquees, marqueesChildren, isVertical, props);
|
|
3073
4027
|
// Calculate dimensions and duplicates
|
|
3074
4028
|
const containerMarqueeWidth = containerMarquee.offsetWidth;
|
|
3075
|
-
// const marqueeHeight = marquees[0].offsetHeight;
|
|
3076
4029
|
const marqueeChildrenWidth = marqueesChildren[0].offsetWidth;
|
|
3077
4030
|
const startX = marqueesChildren[0].offsetLeft;
|
|
4031
|
+
// Clamp scrollSpeed to valid range (1.1 to 4.0)
|
|
4032
|
+
const clampedScrollSpeed = Math.min(4, Math.max(1.1, scrollSpeed));
|
|
3078
4033
|
setMarqueeDuplicates(calculateDuplicates(marqueeChildrenWidth, containerMarqueeWidth, isVertical, props));
|
|
3079
4034
|
// Calculate total width and set marquee styles
|
|
3080
|
-
const totalWidth = gsap.utils
|
|
4035
|
+
const totalWidth = gsap$1.utils
|
|
3081
4036
|
.toArray(marquee.children)
|
|
3082
4037
|
.map((child) => child.offsetWidth)
|
|
3083
4038
|
.reduce((a, b) => a + b, 0);
|
|
3084
|
-
gsap.set(marquees, {
|
|
4039
|
+
gsap$1.set(marquees, {
|
|
3085
4040
|
minWidth: getMinWidth(marqueesChildren, totalWidth, containerMarqueeWidth, props),
|
|
3086
4041
|
flex: fill ? "0 0 auto" : "1",
|
|
3087
4042
|
});
|
|
3088
4043
|
// Create appropriate animation based on fill setting
|
|
3089
4044
|
coreAnimation(fill ? marqueesChildren : marquees, startX, tl, isReverse, props);
|
|
4045
|
+
/**
|
|
4046
|
+
* GSAP Observer for scroll-based speed control
|
|
4047
|
+
*
|
|
4048
|
+
* This creates an interactive experience where users can control
|
|
4049
|
+
* the marquee speed and direction through mouse wheel scrolling.
|
|
4050
|
+
*
|
|
4051
|
+
* Behavior:
|
|
4052
|
+
* - Scroll down: Increases speed in normal direction
|
|
4053
|
+
* - Scroll up: Increases speed in reverse direction or slows normal direction
|
|
4054
|
+
* - Speed changes are smoothly animated with acceleration and deceleration phases
|
|
4055
|
+
* - ScrollSpeed multiplier is applied and clamped to valid range
|
|
4056
|
+
*/
|
|
4057
|
+
Observer.create({
|
|
4058
|
+
onChangeY(self) {
|
|
4059
|
+
if (!followScrollDir)
|
|
4060
|
+
return;
|
|
4061
|
+
let factor = clampedScrollSpeed * (isReverse ? -1 : 1);
|
|
4062
|
+
if (self.deltaY < 0) {
|
|
4063
|
+
factor *= -1;
|
|
4064
|
+
}
|
|
4065
|
+
/**
|
|
4066
|
+
* Create smooth speed transition animation
|
|
4067
|
+
*
|
|
4068
|
+
* Phase 1: Quick acceleration to new speed (0.2s)
|
|
4069
|
+
* - timeScale: Controls timeline playback speed (higher = faster)
|
|
4070
|
+
* - factor * 2.5: Initial speed boost for responsive feel
|
|
4071
|
+
* - overwrite: Cancels any previous speed animations
|
|
4072
|
+
*
|
|
4073
|
+
* Phase 2: Gradual deceleration to sustained speed (1s delay + 1s duration)
|
|
4074
|
+
* - factor / 2.5: Settle to a more moderate sustained speed
|
|
4075
|
+
* - "+=0.3": Wait 0.3 seconds before starting deceleration
|
|
4076
|
+
*/
|
|
4077
|
+
gsap$1
|
|
4078
|
+
.timeline({
|
|
4079
|
+
defaults: {
|
|
4080
|
+
ease: "none",
|
|
4081
|
+
},
|
|
4082
|
+
})
|
|
4083
|
+
.to(tl, {
|
|
4084
|
+
timeScale: factor * 2.5,
|
|
4085
|
+
duration: 0.2,
|
|
4086
|
+
overwrite: true,
|
|
4087
|
+
})
|
|
4088
|
+
.to(tl, { timeScale: factor / 2.5, duration: 1 }, "+=0.3");
|
|
4089
|
+
},
|
|
4090
|
+
});
|
|
3090
4091
|
}, {
|
|
3091
4092
|
dependencies: [marqueeDuplicates],
|
|
3092
4093
|
});
|
|
4094
|
+
const getGradientColor = () => {
|
|
4095
|
+
// Priority order: explicit gradientColor > auto-detected > fallback
|
|
4096
|
+
if (gradientColor) {
|
|
4097
|
+
return gradientColor; // User-specified color takes precedence
|
|
4098
|
+
}
|
|
4099
|
+
if (gradient && effectivelyGradient) {
|
|
4100
|
+
return effectivelyGradient; // Auto-detected background color
|
|
4101
|
+
}
|
|
4102
|
+
return "transparent"; // Default fallback
|
|
4103
|
+
};
|
|
4104
|
+
/**
|
|
4105
|
+
* Generate cloned marquee elements for seamless looping
|
|
4106
|
+
*
|
|
4107
|
+
* Creates multiple copies of the content based on calculated duplicates.
|
|
4108
|
+
* Each clone maintains the same structure and styling as the original.
|
|
4109
|
+
* Memoized to prevent unnecessary re-renders when dependencies haven't changed.
|
|
4110
|
+
*/
|
|
3093
4111
|
const clonedMarquees = useMemo(() => {
|
|
3094
4112
|
if (!Number.isFinite(marqueeDuplicates) || marqueeDuplicates <= 0)
|
|
3095
4113
|
return null;
|
|
3096
4114
|
return Array.from({ length: marqueeDuplicates }, (_, i) => (jsxRuntimeExports.jsx("div", { className: cn("gsap-react-marquee"), children: jsxRuntimeExports.jsx("div", { className: cn("gsap-react-marquee-content", className), children: children }) }, i)));
|
|
3097
4115
|
}, [marqueeDuplicates, className, children]);
|
|
3098
|
-
return (jsxRuntimeExports.jsxs("div", { ref: containerRef,
|
|
4116
|
+
return (jsxRuntimeExports.jsxs("div", { ref: containerRef, style: {
|
|
4117
|
+
"--gradient-color": getGradientColor(),
|
|
4118
|
+
}, className: cn("gsap-react-marquee-container flex w-full overflow-hidden whitespace-nowrap"), children: [jsxRuntimeExports.jsx("div", { ref: marqueeRef, className: cn("gsap-react-marquee"), children: jsxRuntimeExports.jsx("div", { className: cn("gsap-react-marquee-content", className), children: children }) }), clonedMarquees] }));
|
|
3099
4119
|
});
|
|
3100
4120
|
GSAPReactMarquee.displayName = "GSAPReactMarquee";
|
|
3101
4121
|
|
|
3102
|
-
export { calculateDuplicates, cn, coreAnimation, GSAPReactMarquee as default, getMinWidth, setupContainerStyles };
|
|
4122
|
+
export { calculateDuplicates, cn, coreAnimation, GSAPReactMarquee as default, getEffectiveBackgroundColor, getMinWidth, setupContainerStyles };
|
|
3103
4123
|
//# sourceMappingURL=index.esm.js.map
|