yahoo/react-i13n

Viewport checking doesn't happen when scrolling through components inside a scrollable div

ebertb opened this issue · 2 comments

I have a use case where the react components are within a scrollable div, and using window as the target won't work.

It looks like the capability to set different targets was recently added to the "subscribe-ui-event" module (13 days ago). So I tried changing subscribeViewportEvents to supply an options object just to see if it would work:

    subscribeViewportEvents: function () {
      this.subscription =
        subscribe('scrollEnd', this._detectViewport,
                  {target: document.getElementById('scrollable-div')});
    },

At the moment it actually won't work because there seems to be an issue with "scrollEnd" -- but I guess once that's resolved, would it be possible to have a way to specify a different target?

For my use case, I was able to get it working by modifying "subscribe-ui-events" (as mentioned in the link).

I thought about this a bit more, and for my use case the div actually fills the entire window.. but in cases where it doesn't, I think the _detectElement function in ViewportMixin.js will need to be modified to look at the target's clientHeight.