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

"overflow" and "resize" won't work together

Open g1091541365 opened this issue 4 years ago • 3 comments

It seems that this part of the code has caused this bug. When the prop "overflow" is set, the code doesn't add resize listener.

if (this.props.overflow) {
  const parent = scrollParent(this.ref);
  if (parent && typeof parent.getAttribute === 'function') {
    const listenerCount = 1 + +parent.getAttribute(LISTEN_FLAG);
    if (listenerCount === 1) {
      parent.addEventListener('scroll', finalLazyLoadHandler, passiveEvent);
    }
    parent.setAttribute(LISTEN_FLAG, listenerCount);
  }
} else if (listeners.length === 0 || needResetFinalLazyLoadHandler) {
  const { scroll, resize } = this.props;

  if (scroll) {
    on(scrollport, 'scroll', finalLazyLoadHandler, passiveEvent);
  }

  if (resize) {
    on(window, 'resize', finalLazyLoadHandler, passiveEvent);
  }
}

g1091541365 avatar Dec 25 '20 02:12 g1091541365

Is this solved by now?

TanyaTPG avatar Nov 12 '21 13:11 TanyaTPG

I am having the same issue, when I have specified overflow prop, and window resize event doesn't load unless I scroll the container div's scroller. Please provide details on solution to this problem..

TanyaTPG avatar Nov 12 '21 13:11 TanyaTPG

I've solved this problem by using the utility forceCheck. Every time the window resizes, I call it manualy. It seems wirely, but it helps indeed.

g1091541365 avatar Jun 29 '22 08:06 g1091541365