Skip to content

Commit

Permalink
feat(animations) : jump animations
Browse files Browse the repository at this point in the history
  • Loading branch information
Mutesa-Cedric committed Sep 26, 2023
1 parent 1a5fe4e commit 8c1c9ed
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/HOC/wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import RevealBase from '../lib/Base.js'
* @param {React.ReactNode} children
* @returns {React.ReactNode}

Check warning on line 14 in src/HOC/wrapper.tsx

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc @returns description
*/
export default function wrapper(props: { when: any; in: any }, inEffect: any, outEffect: any, children: string | number | boolean |
export default function wrapper(props: { when: any; in: any, }, inEffect: any, outEffect: any, children: string | number | boolean |

Check failure on line 16 in src/HOC/wrapper.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected separator (,)
React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined) {
if ('in' in props)
props.when = props.in
Expand Down
38 changes: 38 additions & 0 deletions src/animations/simple/Jump.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import wrapper from '@/HOC/wrapper';

Check failure on line 1 in src/animations/simple/Jump.ts

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon
import { animation, defaults } from '@/lib/defaultConfigs';

Check failure on line 2 in src/animations/simple/Jump.ts

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon


Check failure on line 4 in src/animations/simple/Jump.ts

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed
const rule = `
from, 20%, 53%, 80%, to {
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
transform: translate3d(0,0,0);
}
40%, 43% {
animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
transform: translate3d(0, -30px, 0);
}
70% {
animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
transform: translate3d(0, -15px, 0);
}
90% {
transform: translate3d(0, -4px, 0);
}
`;

Check failure on line 24 in src/animations/simple/Jump.ts

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon

let name: string | undefined;

Check failure on line 26 in src/animations/simple/Jump.ts

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon
function make() {
return name || (name = animation(rule));
}


function Jump({ children, out, timeout, duration = defaults.duration, delay = defaults.delay, count = defaults.count, forever, ...props } = defaults) {

Check warning on line 32 in src/animations/simple/Jump.ts

View workflow job for this annotation

GitHub Actions / lint

'out' is assigned a value but never used. Allowed unused vars must match /^_/u
const effect = { make, duration: timeout === undefined ? duration : timeout, delay, forever, count, style: { animationFillMode: 'both', } };
// @ts-expect-error(some props are not allowed, this will be fixed later)
return wrapper(props, effect, false, children);
}

export default Jump;
7 changes: 6 additions & 1 deletion src/lib/defaultConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export const namespace = 'react-swiftreveal'

// default values

export const defaults = { duration: 1000, delay: 0, count: 1 }
export const defaults: {
duration: number;
delay: number;
count: number;
[key: string]: any;
} = { duration: 1000, delay: 0, count: 1 }
export let ssr = true
export let observerMode = false
export let raf: WindowRequestAnimationFrame = cb => setTimeout(cb, 66)
Expand Down

0 comments on commit 8c1c9ed

Please sign in to comment.