How to use the react-spring/web.cjs.useSpring function in react-spring

To help you get started, we’ve selected a few react-spring examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mui-org / material-ui / docs / src / pages / components / modal / SpringModal.js View on Github external
const Fade = React.forwardRef(function Fade(props, ref) {
  const { in: open, children, onEnter, onExited, ...other } = props;
  const style = useSpring({
    from: { opacity: 0 },
    to: { opacity: open ? 1 : 0 },
    onStart: () => {
      if (open && onEnter) {
        onEnter();
      }
    },
    onRest: () => {
      if (!open && onExited) {
        onExited();
      }
    },
  });

  return (
github mui-org / material-ui / docs / src / pages / components / popper / SpringPopper.tsx View on Github external
const Fade = React.forwardRef(function Fade(props, ref) {
  const { in: open, children, onEnter, onExited, ...other } = props;
  const style = useSpring({
    from: { opacity: 0 },
    to: { opacity: open ? 1 : 0 },
    onStart: () => {
      if (open && onEnter) {
        onEnter();
      }
    },
    onRest: () => {
      if (!open && onExited) {
        onExited();
      }
    },
  });

  return (
github mui-org / material-ui / docs / src / pages / components / tree-view / CustomizedTreeView.tsx View on Github external
function TransitionComponent(props: TransitionProps) {
  const style = useSpring({
    from: { opacity: 0, transform: 'translate3d(20px,0,0)' },
    to: { opacity: props.in ? 1 : 0, transform: `translate3d(${props.in ? 0 : 20}px,0,0)` },
  });

  return (
    
      
    
  );
}
github kalmhq / kalm / src / widgets / FileTree / index.tsx View on Github external
function TransitionComponent(props: any) {
  const style = useSpring({
    from: { opacity: 0, transform: "translate3d(30px,0,0)" },
    to: {
      opacity: props.in ? 1 : 0,
      transform: `translate3d(${props.in ? 0 : 30}px,0,0)`
    }
  });

  return (
    
      
    
  );
}
github kalmhq / kalm / frontend / src / widgets / FileTree / index.tsx View on Github external
function TransitionComponent(props: any) {
  const style = useSpring({
    from: { opacity: 0, transform: "translate3d(30px,0,0)" },
    to: {
      opacity: props.in ? 1 : 0,
      transform: `translate3d(${props.in ? 0 : 30}px,0,0)`,
    },
  });

  return (
    
      
    
  );
}
github mui-org / material-ui / docs / src / pages / components / tree-view / CustomizedTreeView.js View on Github external
function TransitionComponent(props) {
  const style = useSpring({
    from: { opacity: 0, transform: 'translate3d(20px,0,0)' },
    to: { opacity: props.in ? 1 : 0, transform: `translate3d(${props.in ? 0 : 20}px,0,0)` },
  });

  return (
    
      
    
  );
}
github mui-org / material-ui / docs / src / pages / components / popper / SpringPopper.js View on Github external
const Fade = React.forwardRef(function Fade(props, ref) {
  const { in: open, children, onEnter, onExited, ...other } = props;
  const style = useSpring({
    from: { opacity: 0 },
    to: { opacity: open ? 1 : 0 },
    onStart: () => {
      if (open && onEnter) {
        onEnter();
      }
    },
    onRest: () => {
      if (!open && onExited) {
        onExited();
      }
    },
  });

  return (
github mui-org / material-ui / docs / src / pages / components / modal / SpringModal.tsx View on Github external
const Fade = React.forwardRef(function Fade(props, ref) {
  const { in: open, children, onEnter, onExited, ...other } = props;
  const style = useSpring({
    from: { opacity: 0 },
    to: { opacity: open ? 1 : 0 },
    onStart: () => {
      if (open && onEnter) {
        onEnter();
      }
    },
    onRest: () => {
      if (!open && onExited) {
        onExited();
      }
    },
  });

  return (
github WordPress / gutenberg / packages / block-editor / src / components / block-list / moving-animation.js View on Github external
if ( prefersReducedMotion ) {
			return;
		}
		ref.current.style.transform = 'none';
		const destination = ref.current.getBoundingClientRect();
		const newTransform = {
			x: previous ? previous.left - destination.left : 0,
			y: previous ? previous.top - destination.top : 0,
		};
		ref.current.style.transform = newTransform.x === 0 && newTransform.y === 0 ?
			undefined :
			`translate3d(${ newTransform.x }px,${ newTransform.y }px,0)`;
		triggerAnimation();
		setTransform( newTransform );
	}, [ triggerAnimationOnChange ] );
	const animationProps = useSpring( {
		from: transform,
		to: {
			x: 0,
			y: 0,
		},
		reset: triggeredAnimation !== finishedAnimation,
		config: { mass: 5, tension: 2000, friction: 200 },
		immediate: prefersReducedMotion,
	} );

	return {
		transformOrigin: 'center',
		transform: interpolate(
			[
				animationProps.x,
				animationProps.y,
github simonccarter / react-conf-videos / src / components / Header / Header.tsx View on Github external
export const Header: React.FunctionComponent = ({
  title,
  titleLink,
  tagline
}) => {
  const titleRef = React.useRef(null);
  const taglineRef = React.useRef(null);
  const propsTitle = useSpring({ ...transition, ref: titleRef });
  const propsTagline = useSpring({ ...transition, ref: taglineRef });
  useChain([titleRef, taglineRef], [0, 0.2]);

  return (
    <header>
      
      <div>
        <h1>
          
            {title}
          
        </h1>
        </div></header>