react-reveal
Version:
Really simple way to add reveal on scroll animation to your React app.
60 lines (47 loc) • 1.36 kB
JavaScript
/*
* Tada React Component
*
* Copyright © Roman Nosov 2017
* Original CSS Effect - Copyright (c) 2016 Daniel Eden
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import { bool, number } from 'prop-types';
import wrap from '../lib/wrap';
import { animation, defaults } from '../lib/globals';
const
propTypes = {
duration: number,
timeout: number,
delay: number,
count: number,
forever: bool,
};
const rule = `
from {
transform: scale3d(1, 1, 1);
}
10%, 20% {
transform: scale3d(.9, .9, .9) rotate3d(0, 0, 1, -3deg);
}
30%, 50%, 70%, 90% {
transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg);
}
40%, 60%, 80% {
transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg);
}
to {
transform: scale3d(1, 1, 1);
}
`;
let name = false;
function make() {
return name || (name = animation(rule));
}
function Tada({ children, out, timeout, duration = defaults.duration, delay = defaults.delay, count = defaults.count, forever, ...props } = defaults) {
const effect = { make, duration: timeout === undefined ? duration : timeout, delay, forever, count, style: { animationFillMode: 'both', } };
return wrap(props, effect, false, children, true);
}
Tada.propTypes = propTypes;
export default Tada;