How to use the react-spring.config.molasses 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 Vizzuality / trase / frontend / scripts / react-components / home / banner / banner.component.jsx View on Github external
function Banner() {
  const [index, set] = useState(0);
  const [backgroundInterval, setBackgroundInterval] = useState();
  const transitions = useTransition(slides[index], item => item.id, {
    from: { opacity: 0 },
    enter: { opacity: 1 },
    leave: { opacity: 0 },
    config: config.molasses
  });

  useEffect(() => {
    setBackgroundInterval(setInterval(() => set(state => (state + 1) % 2), 6000));
    return function cleanup() {
      clearInterval(backgroundInterval);
    };
  // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);

  return (
    <div>
      {transitions.map(({ item, props, key }) =&gt; (
        &lt;&gt;
          <div>
          </div></div>
github react-spring / react-spring.io / src / common / components.js View on Github external
export const RewindSpringProvider = function({children}) {
  const [flip, set] = useState(false)
  const animatedProps = useSpring({
    reset: true,
    reverse: flip,
    from: {x: 0},
    x: 1,
    delay: 200,
    config: config.molasses,
    onRest: () =&gt; set(!flip)
  })

  return (
    <div>
      
    </div>
  )
}
github react-spring / react-spring-examples / demos / hooks / image-fade / index.js View on Github external
export default function App() {
  const [index, set] = useState(0)

  const transitions = useTransition(slides[index], item =&gt; item.id, {
    from: { opacity: 0 },
    enter: { opacity: 1 },
    leave: { opacity: 0 },
    config: config.molasses,
  })

  useEffect(() =&gt; {
    const id = setInterval(() =&gt; set(state =&gt; ++state % slides.length), 2000)
    return () =&gt; clearInterval(id)
  }, [])

  return transitions.map(({ item, props, key }) =&gt; (
    
  ))
}
github blockstack / blockstack.org / components / photos-grid / index.js View on Github external
const MobileVersion = ({ items, ...rest }) =&gt; {
  const [index, set] = useState(0)
  const itemsWithKeys = items.map((item, key) =&gt; ({
    ...item,
    key
  }))
  const transitions = useTransition(itemsWithKeys[index], (item) =&gt; item.key, {
    from: { opacity: 0 },
    enter: { opacity: 1 },
    leave: { opacity: 0 },
    config: config.molasses
  })

  const delay = itemsWithKeys.length &gt; 3 ? 3200 : 4200
  useEffect(
    () =&gt;
      void setInterval(
        () =&gt; set((state) =&gt; (state + 1) % itemsWithKeys.length),
        delay
      ),
    []
  )
  return (
    
      {transitions.map(({ item, props, key }) =&gt; (
github atherosai / next-react-graphql-apollo-hooks / components / HomePage / Carousel / CarouselHooks.tsx View on Github external
const Carousel: React.FunctionComponent = () => {
  const [items] = useState([
    { title: 'GraphQL changed the way we create software', id: 0 },
    { title: 'Learn about GraphQL language for free in the browser', id: 1 },
    { title: 'Learn how to be Lead frontend engineer with GraphQL driven React and Apollo applications', id: 2 },
  ]);
  const [index, setIndex] = useState(0);

  const heightProps = useSpring({
    config: config.slow,
    from: { height: '0px' },
    to: { height: '700px' },
  });
  const opacityProps = useSpring({
    config: config.molasses,
    delay: 400,
    from: { opacity: 0 },
    to: { opacity: 1 },
  });

  const fadingTextPropsTransition = useTransition(items[index], (item) => item.id, {
    from: { opacity: 0 },
    enter: { opacity: 1 },
    leave: { opacity: 0 },
    config: { tension: 220, friction: 120 },
  });

  useEffect(() => {
    const interval = setInterval(() => {
      setIndex((state) => (state + 1) % items.length);
    }, 4000);
github fillipvt / portfolio / packages / web / next-main / components / Icon.js View on Github external
const Icon = (props) =&gt; {
  return (
    
      {styles =&gt; (
        
      )}
    
  );
}