How to use the react-use.useIntersection function in react-use

To help you get started, we’ve selected a few react-use 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 jannisborn / covid19_pocus_ultrasound / pocovidscreen / resources / js / components / VideoPresentation / VideoPresentation.js View on Github external
function useAnimate(ref, animated, setAnimated) {
    const threshold = .45;
    const onScreen = useIntersection(ref, {
        root: null,
        rootMargin: '0px',
        threshold: threshold
    });

    const animate = (wrapper, title, video, image) => {

        if (animated === 'initial') {
            let tl = new TimelineLite();
            tl.fromTo(wrapper, 1.67,
                {opacity: 0, y: 800, ease: 'power4.out'},
                {opacity: 1, y: 0, ease: 'power4.out'}
            ).fromTo(title, .87,
                {opacity: 0, y: 100, ease: 'power4.out'},
                {opacity: 1, y: 0, ease: 'power4.out'}, .4
            ).fromTo(video, 1.7,
github jannisborn / covid19_pocus_ultrasound / frontend / src / components / VideoPresentation / VideoPresentation.js View on Github external
function useAnimate(ref, animated, setAnimated) {
    const threshold = .45;
    const onScreen = useIntersection(ref, {
        root: null,
        rootMargin: '0px',
        threshold: threshold
    });

    const animate = (wrapper, title, video, image) => {

        if (animated ==='initial') {
            let tl = new TimelineLite();
            tl.fromTo(wrapper, 1.67,
                {opacity: 0, y: 800, ease: 'power4.out'},
                {opacity: 1, y: 0, ease: 'power4.out'}
            ).fromTo(title, .87,
                {opacity: 0, y: 100, ease: 'power4.out'},
                {opacity: 1, y: 0, ease: 'power4.out'}, .4
            ).fromTo(video, 1.7,
github jannisborn / covid19_pocus_ultrasound / pocovidscreen / resources / js / utils / animation.js View on Github external
export function useFadeInOnScroll(ref) {
    const threshold = .45;
    const onScreen = useIntersection(ref, {
        root: null,
        rootMargin: '0px',
        threshold: threshold
    });

    const fadeIn = (el) => {
        gsap.to(el, .67, {opacity: 1, y: -30, stagger: {amount: .6}, ease: 'power4.out'})
    };

    if (ref.current && onScreen && onScreen.intersectionRatio >= threshold) {
        fadeIn(ref.current.querySelectorAll('.fadeIn'));
    }
}
github seek-oss / playroom / src / Playroom / Preview / Iframe.tsx View on Github external
export default function Iframe({
  intersectionRootRef,
  style,
  src,
  ...restProps
}: IframeProps) {
  const [loaded, setLoaded] = useState(false);
  const [renderedSrc, setRenderedSrc] = useState(null);
  const iframeRef = useRef(null);
  const intersection = useIntersection(iframeRef, {
    root: intersectionRootRef.current,
    rootMargin: '800px',
    threshold: 0
  });

  const intersectionRatio = intersection?.intersectionRatio ?? null;

  useEffect(() => {
    if (intersectionRatio === null) {
      return;
    }

    if (intersectionRatio > 0 && src !== renderedSrc) {
      setRenderedSrc(src);
    }
  }, [intersectionRatio, src, renderedSrc]);
github jannisborn / covid19_pocus_ultrasound / pocovidscreen / resources / ui / src / components / VideoPresentation / VideoPresentation.js View on Github external
function useAnimate(ref, animated, setAnimated) {
    const threshold = .45;
    const onScreen = useIntersection(ref, {
        root: null,
        rootMargin: '0px',
        threshold: threshold
    });

    const animate = (wrapper, title, video, image) => {

        if (animated === 'initial') {
            let tl = new TimelineLite();
            tl.fromTo(wrapper, 1.67,
                {opacity: 0, y: 800, ease: 'power4.out'},
                {opacity: 1, y: 0, ease: 'power4.out'}
            ).fromTo(title, .87,
                {opacity: 0, y: 100, ease: 'power4.out'},
                {opacity: 1, y: 0, ease: 'power4.out'}, .4
            ).fromTo(video, 1.7,