Service Portal - window.addEventListener('scroll') not working?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2020 01:35 AM
I need to check on a service portal if the user scrolls down a certain amount, but it doesn't seem like window.addEventListener('scroll', function(e) is firing.
var last_known_scroll_position = 0;
var ticking = false;
console.log('this does appear in the console log');
function doSomething(scroll_pos) {
// Do something with the scroll position
console.log('this does not appear in the console log');
}
window.addEventListener('scroll', function(e) {
last_known_scroll_position = window.scrollY;
console.log('not this either');
if (!ticking) {
window.requestAnimationFrame(function() {
doSomething(last_known_scroll_position);
ticking = false;
});
ticking = true;
}
});
Does anyone have any idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2020 09:09 AM
I know window has some issues in service portal, you might need to use top instead/in addition. Alternatively, you could always use AngularJS. A quick google search brought me to this post, might be what you're looking for: https://stackoverflow.com/questions/44100053/how-to-bind-scroll-event-on-element-in-angularjs-direct...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2020 11:08 AM
Please take a look at below:
Please mark my response as correct and helpful if it helped solved your question.
-Thanks