Scroll event does't appear to trigger with window.scrollTo
See original GitHub issueI need to detect changes to the DOM after a scroll event, however browser.document.window.scrollTo()
doesn’t appear to do anything.
This is what I have:
var assert = require('assert'),
Browser = require('zombie');
Browser.localhost('http://localhost:8080', 8080);
var browser = Browser.create();
it('Should load content on scroll', function(done){
browser.visit('/', function(error){
assert.ifError(error);
browser.assert.success();
// this event never triggers
browser.document.window.addEventListener('scroll', function(){
console.log('scrolling...');
});
browser.document.window.scrollTo(100, 100);
console.log(browser.document.documentElement.scrollTop); // outputs '0'
console.log(browser.document.documentElement.scrollLeft); // outputs '0'
done();
});
});
p.s This thing is amazing 👍
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to trigger an on scroll event without scrolling
If you want to fire a scroll event, just literally scroll to where you already are by typing window.scrollTo(window.scrollX, window.
Read more >Document: scroll event - Web APIs - MDN Web Docs - Mozilla
The scroll event fires when the document view has been scrolled. To detect when scrolling has completed, see the Document: scrollend event.
Read more >JavaScript Scroll Events, Event Throttling & Passive Events
In this tutorial, you will learn about the JavaScript scroll events and how to handle scroll event properly.
Read more >Window scrollTo() Method - W3Schools
Window scrollTo () ; Syntax. window.scrollTo(x, y) ; Parameters · Required. The coordinate to scroll to (horizontally), in pixels. y, Required. The coordinate...
Read more >How to detect a window scroll event in a Reactive application
$(window).scroll(function() { if($(window).scrollTop() + $(window).height() > $(document).height() - 100) { ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
*Disclaimer: I haven’t used zombie that much, I’ve only stumbled here from a Google Search.
I was having the same issue in Firefox Development Edition and Microsoft Edge. I’m not sure if Chrome has this issue or not. I was able to remedy the issue by calling
window.dispatchEvent(new Event('scroll'));
after the window.scrollTo(…) statement.I’m not sure if this will help everybody, but it might help somebody.
I don’t think this is implemented anywhere. This is classical open source, contributors solve whatever problem they have, and contribute it upstream if they want to. No one is working from a roadmap.