baby-i-am-faded
Advanced tools
Comparing version 4.0.11 to 4.0.12
@@ -33,2 +33,3 @@ import React, { ComponentPropsWithoutRef, ElementType, FC, ReactNode } from 'react'; | ||
waitMount?: boolean; | ||
disabled?: boolean; | ||
/** | ||
@@ -98,2 +99,3 @@ * The timing function | ||
waitMount?: boolean; | ||
disabled?: boolean; | ||
/** | ||
@@ -100,0 +102,0 @@ * The timing function |
@@ -51,4 +51,7 @@ "use strict"; | ||
}; | ||
exports.Faded = (0, react_1.forwardRef)(({ as: As = 'div', cascade = false, waitMount = false, duration, threshold = 0.2, className = '', cascadeIncrement, triggerOnce = false, animationName, timingFunction, whenInView = false, delay = 0, style, children, ...rest }, ref1) => { | ||
exports.Faded = (0, react_1.forwardRef)(({ as: As = 'div', cascade = false, disabled = false, waitMount = false, duration, threshold = 0.2, className = '', cascadeIncrement, triggerOnce = false, animationName, timingFunction, whenInView = false, delay = 0, style, children, ...rest }, ref1) => { | ||
const variablesStyle = (0, react_1.useMemo)(() => { | ||
if (disabled) { | ||
return; | ||
} | ||
const variablesStyle = { ...style }; | ||
@@ -80,3 +83,3 @@ if (cascadeIncrement) { | ||
return variablesStyle; | ||
}, [style, animationName, delay, duration, timingFunction, cascade]); | ||
}, [style, animationName, delay, duration, timingFunction, cascade, disabled]); | ||
const [inView, setInView] = (0, react_1.useState)(() => !whenInView && !waitMount ? true : false); | ||
@@ -99,6 +102,8 @@ let { ref: ref2, inView: _inView = true } = (0, react_intersection_observer_1.useInView)({ | ||
const ref = useCombineRefs(ref1, ref2); | ||
return (react_1.default.createElement(As, { style: variablesStyle, className: className + | ||
(inView | ||
? ` biaf biaf${cascade ? 'Cascade' : 'NonCascade'}` | ||
: ' biaf biafHidden'), ref: ref, ...rest }, children)); | ||
return (react_1.default.createElement(As, { style: variablesStyle, className: disabled | ||
? className | ||
: className + | ||
(inView | ||
? ` biaf biaf${cascade ? 'Cascade' : 'NonCascade'}` | ||
: ' biaf biafHidden'), ref: ref, ...rest }, children)); | ||
}); | ||
@@ -105,0 +110,0 @@ exports.FadedText = (0, react_1.forwardRef)(function FadedText({ as: As = 'div', duration, waitMount, threshold = 0.2, className = '', cascadeIncrement = 100, triggerOnce = false, animationName = 'babyFadeTextUp', timingFunction, whenInView = false, delay = 0, style, children, ...rest }, ref1) { |
@@ -33,2 +33,3 @@ import React, { ComponentPropsWithoutRef, ElementType, FC, ReactNode } from 'react'; | ||
waitMount?: boolean; | ||
disabled?: boolean; | ||
/** | ||
@@ -98,2 +99,3 @@ * The timing function | ||
waitMount?: boolean; | ||
disabled?: boolean; | ||
/** | ||
@@ -100,0 +102,0 @@ * The timing function |
@@ -25,4 +25,7 @@ import React, { forwardRef, useCallback, useEffect, useMemo, useState, } from 'react'; | ||
}; | ||
export const Faded = forwardRef(({ as: As = 'div', cascade = false, waitMount = false, duration, threshold = 0.2, className = '', cascadeIncrement, triggerOnce = false, animationName, timingFunction, whenInView = false, delay = 0, style, children, ...rest }, ref1) => { | ||
export const Faded = forwardRef(({ as: As = 'div', cascade = false, disabled = false, waitMount = false, duration, threshold = 0.2, className = '', cascadeIncrement, triggerOnce = false, animationName, timingFunction, whenInView = false, delay = 0, style, children, ...rest }, ref1) => { | ||
const variablesStyle = useMemo(() => { | ||
if (disabled) { | ||
return; | ||
} | ||
const variablesStyle = { ...style }; | ||
@@ -54,3 +57,3 @@ if (cascadeIncrement) { | ||
return variablesStyle; | ||
}, [style, animationName, delay, duration, timingFunction, cascade]); | ||
}, [style, animationName, delay, duration, timingFunction, cascade, disabled]); | ||
const [inView, setInView] = useState(() => !whenInView && !waitMount ? true : false); | ||
@@ -73,6 +76,8 @@ let { ref: ref2, inView: _inView = true } = useInView({ | ||
const ref = useCombineRefs(ref1, ref2); | ||
return (React.createElement(As, { style: variablesStyle, className: className + | ||
(inView | ||
? ` biaf biaf${cascade ? 'Cascade' : 'NonCascade'}` | ||
: ' biaf biafHidden'), ref: ref, ...rest }, children)); | ||
return (React.createElement(As, { style: variablesStyle, className: disabled | ||
? className | ||
: className + | ||
(inView | ||
? ` biaf biaf${cascade ? 'Cascade' : 'NonCascade'}` | ||
: ' biaf biafHidden'), ref: ref, ...rest }, children)); | ||
}); | ||
@@ -79,0 +84,0 @@ export const FadedText = forwardRef(function FadedText({ as: As = 'div', duration, waitMount, threshold = 0.2, className = '', cascadeIncrement = 100, triggerOnce = false, animationName = 'babyFadeTextUp', timingFunction, whenInView = false, delay = 0, style, children, ...rest }, ref1) { |
{ | ||
"name": "baby-i-am-faded", | ||
"_": "[bump if baby-i-am-faded]", | ||
"version": "4.0.11", | ||
"version": "4.0.12", | ||
"description": "Reveal animation for react", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47998
1008