react-component / m-list-view

ReactNative ListView Web Port
http://react-component.github.io/m-list-view/
85 stars 28 forks source link

throttle function does not work on my Android device #19

Open AleCaste opened 7 years ago

AleCaste commented 7 years ago

Hello, The throttle function that is found on [project]/es/util.js does not seem to work on my Android device when making the listview scroll with a single fast touch gesture. The _onScroll handler is executed just once when the listview start scrolling (right after the touch gesture is performed) but then the listview start scrolling but no further _onScroll calls are registered. For some reason the throttle function that is being used is NOT triggering calls every _this.props.scrollEventThrottle milliseconds. On my desktop PC everything seems to be working well though. I tried to replace the throttle function with this version I found here: https://stackoverflow.com/a/27078401/3621841 ... and this indeed works perfectly on both my desktop PC and my Android device.

So it seems this is a better function to use and I would like to ask you if you can make the change on the official version of the library if all your tests are passed. Please let me know. Thanks a lot!

warmhug commented 7 years ago

What is your rmc-list-view version?

cc @zhang740 this issue is concerned.

AleCaste commented 7 years ago

I forgot to mention that. Version 0.8.6 The throttle function being used on this version is this one:

export function throttle(fn, delay) {
  var allowSample = true;
  return function _throttle(e) {
    if (allowSample) {
      allowSample = false;
      setTimeout(function () {
        allowSample = true;
      }, delay);
      fn(e);
    }
  };
}

And, as I said, this function is not working on my Android device when using Chrome. It only calls fn once.

zhang740 commented 6 years ago

@AleCaste The lastest version is rewrite this, is resolved?

AleCaste commented 6 years ago

Hello! I tested v0.11.1 and it definitely works. You may close this issue now. Thanks! (by the way, great library!)

warmhug commented 6 years ago

😶 @AleCaste You should be right, our original throttle function has a problem.