Using scroll to programatically?
See original GitHub issueHey!
I’m trying to implement scrolling programatically, I have a method called calculate
that when called - I validate a form, submit a HTTP request then I want to scroll to an element.
Here is the barebones of what I have.
import Vue from 'vue';
import VueScrollTo from 'vue-scrollto';
Vue.use(VueScrollTo);
new Vue({
el: '#app',
methods: {
calculate: function() {
// Validation
// HTTP request
// ...
// Then scroll
VueScrollTo.scrollTo('#calculator');
}
}
});
At the moment, it doesn’t scroll - am I doing something wrong? Or should this be working?
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (3 by maintainers)
Top Results From Across the Web
How can I scroll programmatically a div with its own scrollbars?
I've setup a small example in jsFiddle that demonstrates how it works. The example shows how you "scroll to" the third p in...
Read more >Programmatically scroll to a dynamically created div - CodePen
1. <p>Programmatically scroll to a dynamically created div</p> ; 2. <button onclick="createItem().then(randomColorLastItem()).then(scrollToLastItem())">Scroll to ...
Read more >Element.scroll() - Web APIs - MDN Web Docs
Chrome Edge
scroll Full support. Chrome61. Toggle history Full support. Edge79. T...
options.behavior parameter Full support. Chrome61. Toggle history Full support. Edge79. T...
options.left parameter Full...
Read more >Moving, scrolling, and resizing a window - JavaScript Kit
The scrollBy() and scrollTo() methods allow you to programmatically scroll the window either up-down, left-right, or both. Here they are, neatly listed in...
Read more >Scrolling Programmatically - WinForms GridView Control
Learn how you can scroll to a particular row/column at run time in WinForms GridView. ... You can scroll programmatically using the following...
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
@rigor789 thanks a ton! Super quick response and right on the money.
I ended up taking part of atomek’s solution (used ‘linear’ for easing) and have this for my final working code (triggered to reset to the top of my Vue instance prior to trigger a router.push to the next view):
this.$scrollTo('#app', 200, { easing: 'linear' })
Should anyone else look to use the above, just replace #app with whatever you want to scroll to.
Hey, please specify a duration and options like so: