question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using scroll to programatically?

See original GitHub issue

Hey!

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:closed
  • Created 7 years ago
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
necevilcommented, Apr 10, 2017

@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.

2reactions
rigor789commented, Mar 16, 2017

Hey, please specify a duration and options like so:

VueScrollTo.scrollTo('#calculator', 500, { easing: VueScrollTo.easing['ease'] } );
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found