mercs600 / vue2-perfect-scrollbar

Vue.js wrapper for perfect scrollbar
https://mercs600.github.io/vue2-perfect-scrollbar/
MIT License
275 stars 43 forks source link

this.$emit integration #42

Closed nitrowo closed 4 years ago

nitrowo commented 4 years ago

hi,

you can integrate this.$emit for events, it's boring to window.addEventListener :)

ty

mercs600 commented 4 years ago

@nitrowo you can listen to all perfect-scrollbar events in vuejs way.

<template>
  <div id="app">
    <perfect-scrollbar @ps-scroll-y="onScroll" ref="scrollbar">
      <div>your content here</div>
    </perfect-scrollbar>
  </div>
</template>

<script>
export default {
  methods: {
    onScroll(event) {
      console.log(this.$refs.scrollbar.ps, event);
    }
  }
};
</script>

more events you can find in perfect scrollbar docs -> https://github.com/mdbootstrap/perfect-scrollbar#events

I added an example to documentation to make it more clear for everyone.