Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to show the bar when I initialize it #24

Open
husilang opened this issue Nov 24, 2017 · 6 comments
Open

how to show the bar when I initialize it #24

husilang opened this issue Nov 24, 2017 · 6 comments

Comments

@husilang
Copy link

Hi
In you demo, the scrollbar is always showing. But in my project, The scrollbar only display when I scrolling, I want it to be displayed when the component was initialized for the first time. What should I do?
Thank you!

@hotrush
Copy link

hotrush commented Dec 28, 2017

Same issue here

@zaclem01
Copy link

zaclem01 commented Feb 2, 2018

If you're loading your content of the scroll container with an ajax call, you'll need to have the scroll component wait for the response. Otherwise, it initializes with a zero height container, which makes the scrollbar itself hide.

@hotrush
Copy link

hotrush commented Feb 4, 2018

@zaclem01 maybe any resize/re-render event on data changing? Otherwise it is some useles, because vue js is a modern framework for app with dynamic data, and most of this data can be loaded via ajax)

@raulhuelamo
Copy link

I added a reference to the vue2-scrollbar component, then after the async data has been fetched, I call the calculateSize() method from the scrollbar reference; works like a charm.

<vue-scroll-bar ref="scrollbar"> ...your content... </vue-scroll-bar>
this.$refs.scrollbar.calculateSize();

Hope it helps

@tmcdos
Copy link

tmcdos commented Mar 25, 2018

You can simply add

    updated ()
    {
      this.calculateSize()
    },

after the mounted() method in the vue-scrollbar source

@login2030
Copy link

My solution

export default {
    components: {
        'vue-scrollbar': require('vue2-scrollbar')
    },
    data() {
        return {
            onceCalculateSizeScroll: true
        };
    },
    updated() {
        if (this.onceCalculateSizeScroll) {
            this.$refs.scrollbar.calculateSize();
            this.onceCalculateSizeScroll = false;
        }
    },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants