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 listen to PS custom events #8

Closed
hfalucas opened this issue Mar 16, 2019 · 2 comments
Closed

How to listen to PS custom events #8

hfalucas opened this issue Mar 16, 2019 · 2 comments

Comments

@hfalucas
Copy link

In the docs says you can listen to Perfect Scrollbar custom events and it refers to the PS documentation where it shows:

container.addEventListener('ps-scroll-x, ...)

In my app I'm trying this but with no success:

<scroll-bar ref="scroll"> ... </scroll-bar>

// error: addEventListener is not a function
mounted () {
    this.$refs.scroll.addEventListenter('ps-scroll-x', () => {
        consolellog(...)
    })
}

// error: nothing happens
mounted () {
    this.$refs.scroll.$el.addEventListenter('ps-scroll-x', () => {
        console.log(...)
    })
}

I am obviously missing something. How can I listen to the PS events?

Thanks in advance.

@mercs600
Copy link
Owner

@hfalucas
you can use vuejs directive to listening events on: https://vuejs.org/v2/guide/events.html
just add @ps-scroll-x to your scrollbar element

<scroll-bar ref="scroll" @ps-scroll-x="someMethodToHandle">

and then

methods: {
  someMethodToHandle() {
   console.log('scroll x')
  }
}

Let's see example here:
https://codesandbox.io/s/00w2rk5k7v

@hfalucas
Copy link
Author

I did try that before opening the issue but I guess "scoll" was not really a word -.-

Thank you @mercs600 for such quick answer and helpful examples.

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

2 participants