react-lineto icon indicating copy to clipboard operation
react-lineto copied to clipboard

Lines in fixed scrolling container

Open GensaGames opened this issue 4 years ago • 5 comments

This might be out of support request, so you can close it, if so. I have scrolling container and lines goes out of bounds. Because it's static, and not dynamic draw, but it could be static within container, right? Is it possible to solve it? Thanks.

Screen Shot 2021-03-23 at 2 08 13 PM

GensaGames avatar Mar 23 '21 21:03 GensaGames

You could try using the within property which is the CSS class name of the container element.

kdeloach avatar Mar 23 '21 21:03 kdeloach

It's already within container. I have this page with vertical scrolling, and within fixed this issue. Now this particular component has also horizontal scrolling.

From the image above there are two rows. First doesn't have too many items and they fit inside the component. The second (image above) has horizontal scroll. I tried to play around with within, but it didn't help.

GensaGames avatar Mar 23 '21 21:03 GensaGames

GensaGames, did you figure this out? I am still having trouble with a vertical scrolling container! When i scroll vertically, the lines stay in place but the rest of my components move. I tried using an onScroll update function which works...but the re rendering constantly causes the lines to flash and lag behind the other components making it unusable

mahir-cognitiv avatar Apr 29 '21 19:04 mahir-cognitiv

@mahir-cognitiv you can add a debounce to reduce the re-render, the following is a custom React hook:

import React, { RefObject, useEffect, useState } from 'react';
import debounce from 'debounce';

export const useUpdaterOnScroll = (ref: RefObject<any>, duration: number = 100) => {
  const [state, updateState] = useState({});
  const forceUpdate = React.useCallback(() => updateState({}), []);
  useEffect(() => {
    const resizeHandler = debounce(() => {
      forceUpdate();
    }, duration);
    window.addEventListener('resize', resizeHandler, false);
    const element = ref?.current;
    element?.addEventListener('scroll', resizeHandler, false);
    return () => {
      window.removeEventListener('resize', resizeHandler);
      element?.removeEventListener('scroll', resizeHandler, false);
    };
  }, [forceUpdate]);

  return state;
};

dongyuwei avatar Sep 15 '21 04:09 dongyuwei

Hello, has this issue been resolved? I have some lines in a react modal instance, the lines are always on top even when I change the modal z index. Please see the screenshot, any suggestions would be welcome. image

rayonhunte avatar May 11 '22 23:05 rayonhunte