recalculate debounce leading vs trailing
See original GitHub issueI’m using simplebar with AngularJS. I need to call recalculate
after a certain angular scope event (after which I’m fairly certain the scroll content is ready and in the DOM). The issue is that recalculate
is debounced with { leading: true, trailing: false }
, so when I call it the call is simply discarded (as various other things trigger recalculate
).I even tried timing out for more than the debounce timeout (currently 100ms) and for some reason this is not working as intended.
I found myself having to manually invoke the original recalculate
like so:
simplebarInstance.__proto__.recalculate.apply(simplebarInstance);
to force a recalculate at the exact point at which I know it should work.
I’m not sure about the rationale behind choosing that recalculate
fire only on the leading edge. Can it be configured with { leading: true, trailing: true }
instead?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Hi @mnzaki , I guess it’s hard to replicate this issue in an isolated scope as it’s quite specific to your use case. I don’t think calling recalculate on trailing debounce could be an issue so I could probably get that in! Thanks for this report, I’m glad you found a workaround for your problem. I’ll see if I can implement this.
it would be very much appreciated if you could publish a patch release soon 😄