3

Like instagram feed autoplay when in view, I would like to understand where the scroll and inview logic will be.

I have this setup:

<ContentList>
  <Item>
  <Item>
  <Item>
  <Item>
</ContentList>

I have window scroll added to ContentList when it mounts. I dont know if thats a good idea because I dont have direct references to Item's dom to know when it is inside viewport.

Whats the best way to approach this?

4
  • 1
    wow this is a loaded question... you may want to consider breaking it up into separate parts. A little direction though... the scroll on contentlist is fine... you need to determine if the scroll position is near the end of your container height.. and if so load more items.. can you clarify what you mean by I dont have direct references to Item's dom to know when it is inside viewport ?? Commented Nov 11, 2015 at 6:02
  • I would suggest to go and read stackoverflow.com/questions/123999/… Commented Nov 11, 2015 at 9:15
  • Thanks everyone for responding. I can apply the element in view logic in vanillaJS but I'm having trouble organizing the logic in reactjs. ContentList doesnt have visibility to Item's dom elements to do the check within the scroll. My understanding is that Owners doesnt know Ownee's internal dom. If I place the scroll event in Item, I would have to have multiple scroll listeners for each Item. Commented Nov 14, 2015 at 2:06
  • I saw this: link Is it a good pattern for the Owner to access the childs methods and ask for the internal element's position? Commented Nov 14, 2015 at 2:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.