Guest User

Untitled

a guest
Feb 16th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. let scrolled;
  2. let div = this.template.querySelector(".resultsscroll");
  3.  
  4. div.onscroll = function() {
  5. scrolled = true;
  6. }
  7.  
  8. let scrollIntervalId = setInterval(() => {
  9. if (scrolled) {
  10. scrolled = false;
  11.  
  12. if (this.aThingINeed && div.scrollHeight - div.scrollTop < 300) {
  13. // do stuff
  14. }
  15. }
  16. }, 750);
  17.  
  18. this.scrollIntervalId = scrollIntervalId;
  19.  
  20. afterRender : function(component, helper, event) {
  21. this.superAfterRender();
  22.  
  23. let scrolled;
  24. let div = component.find('resultsscroll');
  25. if (!$A.util.isEmpty(div)) {
  26. div = div.getElement();
  27. div.onscroll = () => scrolled = true;
  28.  
  29. let scrollIntervalId = setInterval($A.getCallback(() => {
  30. if (scrolled) {
  31. scrolled = false;
  32.  
  33. if (component.get("v.aThingINeed") && div.scrollHeight - div.scrollTop < 300) {
  34. // do stuff
  35. }
  36. }
  37. }), 750);
  38.  
  39. component.set('v.scrollIntervalId', scrollIntervalId);
  40. }
  41. },
  42.  
  43. unrender: function( component, helper ) {
  44. this.superUnrender();
  45.  
  46. window.clearInterval(component.get("v.scrollIntervalId"));
  47. }
Add Comment
Please, Sign In to add comment