Author Topic: Virtual Scrolling - Throttling  (Read 948 times)

Webauthor

  • Pro OEM
  • Jr. Member
  • *
  • Posts: 51
    • View Profile
Virtual Scrolling - Throttling
« on: November 18, 2021, 01:00:52 am »
Hi, I'm not sure how to phrase this question well, so please bear with me. 

I've been using a remote setup for my data along with paging and it works well, but I'd like to get users away from paging and using virtual/infinite scrolling instead.  I have the examples in place and it works, but what I'm finding is that when users move the scrollbar up and down really fast, it kicks off multiple remote requests.  I see in Chrome's console when those requests are cancelled, but they still hit our server and tie up resources. 

I started looking to see if I could use the beforeSend event to throttle requests so that we're not making more than xx requests in a given time period.

Is that something you can help me figure out - so that when users are rapidly scrolling up or down, we're making 1 request at a time to the server?

Thank you

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Virtual Scrolling - Throttling
« Reply #1 on: November 18, 2021, 06:51:33 pm »
It seems very well phrased question to me :)

In current ParamQuery examples, beforeTableView event is used to initiate the remote requests.

Instead of beforeTableView event, scrollStop event seems more suitable for your requirement and getViewPortIndx method can be used to calculate requestPage

https://paramquery.com/pro/api#event-scrollStop

https://paramquery.com/pro/api#method-getViewPortIndx

Please let me know if you need further assistance on this.

Webauthor

  • Pro OEM
  • Jr. Member
  • *
  • Posts: 51
    • View Profile
Re: Virtual Scrolling - Throttling
« Reply #2 on: November 18, 2021, 07:05:15 pm »
Thank you so much :)

This change is working perfectly so far.  I will let you know if we run into any issues.  I greatly appreciate the guidance and help here.