Skip to content

Arrows are displayed if partially hidden #275

Discussion options

You must be logged in to vote

Hi, can do something like this:

const LeftArrow = React.memo(() => {
  const visibility = React.useContext<publicApiType>(VisibilityContext);
  const isFirstItemVisible = visibility.useIsVisible('first', true);
  const someVisible = !!visibility.items.getVisible().length;

  const [disabled, setDisabled] = React.useState(isFirstItemVisible);
  React.useEffect(() => {
    if (someVisible) {
      setDisabled(isFirstItemVisible);
    }
  }, [someVisible, isFirstItemVisible]);

  return (
    <Arrow disabled={disabled} onClick={visibility.scrollPrev} className="left">
      Left
    </Arrow>
  );
});

const RightArrow = React.memo(() => {
  const visibility = React.useContext<publicApiType>(…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by alekseykurylev
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants