react-awesome-reveal 4.0.0-beta.1 → 4.0.0-beta.2

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 CHANGED
@@ -31,8 +31,8 @@
31
31
 
32
32
  - 🎁 **Modern stack** – It is built for modern React and supports React 18
33
33
  - 🏷 **TypeScript support** – It is written in TypeScript to improve the DX
34
- - 🍃 **Lightweight** – Very little footprint on your project and no other dependencies required
35
- - ⚙️ **Uses native APIs** – Intersection Observer and CSS Animations are now supported by all major browsers
34
+ - 🍃 **Lightweight** – Very little footprint on your project
35
+ - ⚙️ **Uses native APIs** – Intersection Observer and CSS Animations are now supported by all browsers
36
36
  - 🚀 **Fast** – Buttery smooth experience thanks to the use of native asynchronous APIs and hardware acceleration
37
37
  - 💅 **Fully customizable** – Define custom animations and let the library render them
38
38
  - 💻 **SSR support** – Server Side Rendering works out-of-the-box
package/dist/main.js CHANGED
@@ -568,83 +568,41 @@ function $6a26e8abc0402dd5$export$f832f653c73e86f8(value) {
568
568
  }
569
569
 
570
570
 
571
- const $c8a4d927fd00b892$var$hiddenCss = $jvNZe$emotionreact.css`
571
+ const $c8a4d927fd00b892$var$hiddenStyles = $jvNZe$emotionreact.css`
572
572
  opacity: 0;
573
573
  `;
574
- const $c8a4d927fd00b892$var$textBaseCss = $jvNZe$emotionreact.css`
574
+ const $c8a4d927fd00b892$var$textBaseStyles = $jvNZe$emotionreact.css`
575
575
  display: inline-block;
576
576
  white-space: pre;
577
577
  `;
578
578
  const $c8a4d927fd00b892$export$9a32a8eb4bb56ca3 = (props)=>{
579
579
  const { cascade: cascade = false , damping: damping = 0.5 , delay: delay = 0 , duration: duration = 1000 , fraction: fraction = 0 , keyframes: keyframes = $059dd4d1a0e7c5c8$export$d8fce5eeb232a07b , triggerOnce: triggerOnce = false , css: revealCss , className: className , style: style , childClassName: childClassName , childStyle: childStyle , children: children , onVisibilityChange: onVisibilityChange , } = props;
580
- if ($6a26e8abc0402dd5$export$bedb7023a7733221(children)) return null;
581
- if ($6a26e8abc0402dd5$export$f832f653c73e86f8(children)) {
582
- const stringifiedChildren = String(children);
583
- return cascade ? $jvNZe$emotionreactjsxruntime.jsx($jvNZe$reactintersectionobserver.InView, {
584
- threshold: fraction,
585
- triggerOnce: triggerOnce,
586
- onChange: onVisibilityChange,
587
- children: ({ inView: inView , ref: ref })=>$jvNZe$emotionreactjsxruntime.jsx("div", {
588
- ref: ref,
589
- className: className,
590
- css: [
591
- revealCss,
592
- $c8a4d927fd00b892$var$textBaseCss
593
- ],
594
- style: style,
595
- children: stringifiedChildren.split("").map((char, index)=>$jvNZe$emotionreactjsxruntime.jsx("span", {
596
- className: className,
597
- css: inView ? $f2597d38a334a0ad$export$cdf1f51c52cf49d8({
598
- keyframes: keyframes,
599
- delay: delay + index * duration * damping,
600
- duration: duration
601
- }) : $c8a4d927fd00b892$var$hiddenCss,
602
- children: char
603
- }, index)
604
- )
605
- })
606
- }) : $jvNZe$emotionreactjsxruntime.jsx($c8a4d927fd00b892$export$9a32a8eb4bb56ca3, {
607
- delay: delay,
608
- duration: duration,
609
- fraction: fraction,
580
+ const animationStyles = $jvNZe$react.useMemo(()=>$f2597d38a334a0ad$export$cdf1f51c52cf49d8({
610
581
  keyframes: keyframes,
611
- triggerOnce: triggerOnce,
612
- css: revealCss,
613
- className: className,
614
- style: style,
615
- children: stringifiedChildren
616
- });
617
- }
618
- if ($jvNZe$reactis.isFragment(children)) return $jvNZe$emotionreactjsxruntime.jsx($jvNZe$reactintersectionobserver.InView, {
619
- threshold: fraction,
620
- triggerOnce: triggerOnce,
621
- onChange: onVisibilityChange,
622
- children: ({ inView: inView , ref: ref })=>$jvNZe$emotionreactjsxruntime.jsx("div", {
623
- ref: ref,
624
- className: className,
625
- css: inView ? [
626
- revealCss,
627
- $f2597d38a334a0ad$export$cdf1f51c52cf49d8({
628
- keyframes: keyframes,
629
- delay: delay,
630
- duration: duration
631
- })
632
- ] : $c8a4d927fd00b892$var$hiddenCss,
633
- style: style,
634
- children: children
635
- })
582
+ duration: duration
583
+ })
584
+ , [
585
+ duration,
586
+ keyframes
587
+ ]);
588
+ if ($6a26e8abc0402dd5$export$bedb7023a7733221(children)) return null;
589
+ if ($6a26e8abc0402dd5$export$f832f653c73e86f8(children)) return $jvNZe$emotionreactjsxruntime.jsx($c8a4d927fd00b892$var$TextReveal, {
590
+ ...props,
591
+ animationStyles: animationStyles,
592
+ children: String(children)
593
+ });
594
+ if ($jvNZe$reactis.isFragment(children)) return $jvNZe$emotionreactjsxruntime.jsx($c8a4d927fd00b892$var$FragmentReveal, {
595
+ ...props,
596
+ animationStyles: animationStyles
636
597
  });
637
598
  return $jvNZe$emotionreactjsxruntime.jsx($jvNZe$emotionreactjsxruntime.Fragment, {
638
599
  children: $jvNZe$react.Children.map(children, (node, index)=>{
639
600
  if (!/*#__PURE__*/ $jvNZe$react.isValidElement(node)) return null;
640
- const nodeCss = node.props.css ? [
641
- node.props.css
642
- ] : [];
643
- nodeCss.push($f2597d38a334a0ad$export$cdf1f51c52cf49d8({
644
- keyframes: keyframes,
645
- delay: delay + (cascade ? index * duration * damping : 0),
646
- duration: duration
647
- }));
601
+ const inViewStyles = [
602
+ revealCss,
603
+ animationStyles
604
+ ];
605
+ const nodeDelay = delay + (cascade ? index * duration * damping : 0);
648
606
  switch(node.type){
649
607
  case "ol":
650
608
  case "ul":
@@ -657,16 +615,7 @@ const $c8a4d927fd00b892$export$9a32a8eb4bb56ca3 = (props)=>{
657
615
  ...node.props.style
658
616
  },
659
617
  children: $jvNZe$emotionreactjsxruntime.jsx($c8a4d927fd00b892$export$9a32a8eb4bb56ca3, {
660
- cascade: cascade,
661
- damping: damping,
662
- delay: delay,
663
- duration: duration,
664
- fraction: fraction,
665
- keyframes: keyframes,
666
- triggerOnce: triggerOnce,
667
- css: revealCss,
668
- childClassName: childClassName,
669
- childStyle: childStyle,
618
+ ...props,
670
619
  children: node.props.children
671
620
  })
672
621
  })
@@ -681,13 +630,11 @@ const $c8a4d927fd00b892$export$9a32a8eb4bb56ca3 = (props)=>{
681
630
  ...node.props,
682
631
  ref: ref,
683
632
  className: cx(childClassName, node.props.className),
684
- css: inView ? [
685
- revealCss,
686
- ...nodeCss
687
- ] : $c8a4d927fd00b892$var$hiddenCss,
633
+ css: inView ? inViewStyles : $c8a4d927fd00b892$var$hiddenStyles,
688
634
  style: {
689
635
  ...childStyle,
690
- ...node.props.style
636
+ ...node.props.style,
637
+ animationDelay: nodeDelay + "ms"
691
638
  }
692
639
  })
693
640
  })
@@ -700,11 +647,11 @@ const $c8a4d927fd00b892$export$9a32a8eb4bb56ca3 = (props)=>{
700
647
  children: ({ inView: inView , ref: ref })=>$jvNZe$emotionreactjsxruntime.jsx("div", {
701
648
  ref: ref,
702
649
  className: className,
703
- css: inView ? [
704
- revealCss,
705
- ...nodeCss
706
- ] : $c8a4d927fd00b892$var$hiddenCss,
707
- style: style,
650
+ css: inView ? inViewStyles : $c8a4d927fd00b892$var$hiddenStyles,
651
+ style: {
652
+ ...style,
653
+ animationDelay: nodeDelay + "ms"
654
+ },
708
655
  children: $jvNZe$emotionreactjsxruntime.jsx($jvNZe$emotionreact.ClassNames, {
709
656
  children: ({ cx: cx })=>$jvNZe$emotionreactjsxruntime.jsx(node.type, {
710
657
  ...node.props,
@@ -721,6 +668,53 @@ const $c8a4d927fd00b892$export$9a32a8eb4bb56ca3 = (props)=>{
721
668
  })
722
669
  });
723
670
  };
671
+ const $c8a4d927fd00b892$var$TextReveal = (props)=>{
672
+ const { animationStyles: animationStyles , cascade: cascade = false , damping: damping = 0.5 , delay: delay = 0 , duration: duration = 1000 , fraction: fraction = 0 , triggerOnce: triggerOnce = false , css: revealCss , className: className , style: style , children: children , onVisibilityChange: onVisibilityChange , } = props;
673
+ const { ref: ref , inView: inView } = $jvNZe$reactintersectionobserver.useInView({
674
+ triggerOnce: triggerOnce,
675
+ threshold: fraction,
676
+ onChange: onVisibilityChange
677
+ });
678
+ return cascade ? $jvNZe$emotionreactjsxruntime.jsx("div", {
679
+ ref: ref,
680
+ className: className,
681
+ css: [
682
+ revealCss,
683
+ $c8a4d927fd00b892$var$textBaseStyles
684
+ ],
685
+ style: style,
686
+ children: children.split("").map((char, index)=>$jvNZe$emotionreactjsxruntime.jsx("span", {
687
+ css: inView ? animationStyles : $c8a4d927fd00b892$var$hiddenStyles,
688
+ style: {
689
+ animationDelay: delay + index * duration * damping + "ms"
690
+ },
691
+ children: char
692
+ }, index)
693
+ )
694
+ }) : $jvNZe$emotionreactjsxruntime.jsx($c8a4d927fd00b892$export$9a32a8eb4bb56ca3, {
695
+ ...props,
696
+ children: children
697
+ });
698
+ };
699
+ const $c8a4d927fd00b892$var$FragmentReveal = (props)=>{
700
+ const { animationStyles: animationStyles , fraction: fraction = 0 , triggerOnce: triggerOnce = false , css: revealCss , className: className , style: style , children: children , onVisibilityChange: onVisibilityChange , } = props;
701
+ const { ref: ref , inView: inView } = $jvNZe$reactintersectionobserver.useInView({
702
+ triggerOnce: triggerOnce,
703
+ threshold: fraction,
704
+ onChange: onVisibilityChange
705
+ });
706
+ const inViewStyles = [
707
+ revealCss,
708
+ animationStyles
709
+ ];
710
+ return $jvNZe$emotionreactjsxruntime.jsx("div", {
711
+ ref: ref,
712
+ className: className,
713
+ css: inView ? inViewStyles : $c8a4d927fd00b892$var$hiddenStyles,
714
+ style: style,
715
+ children: children
716
+ });
717
+ };
724
718
 
725
719
 
726
720
  function $53b8ad22b050830b$var$getStyles(effect) {