
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
vue2-perfect-scrollbar
Advanced tools
Vue.js minimalistic but powerful wrapper for perfect scrollbar
Are you looking compatible version with Vue3 ? check https://github.com/mercs600/vue3-perfect-scrollbar
Because I ❤️ to use perfect-scrollbar in my projects (🙌 utatti). But also because the current solutions on github are outdated or overcomplicated.
Because you want to load perfect-scrollbar to your Vue project in an easy way. But also because this plugin is updated, tested and build by rollup. So you will not find any unnecessary 💩 code in this repo. I hope 🙏.
If you have any reasonable PR you are welcome 🤘
npm install vue2-perfect-scrollbar
yarn add vue2-perfect-scrollbar
import PerfectScrollbar from 'vue2-perfect-scrollbar'
import 'vue2-perfect-scrollbar/dist/vue2-perfect-scrollbar.css'
Vue.use(PerfectScrollbar)
So then you can use this plugin in each component as
<perfect-scrollbar>
<p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
</perfect-scrollbar>
This plugin will generate a container with ".ps" class name, you need to customize the height of the container
/* example */
.ps {
height: 400px;
}
Install method takes additional parameters:
name {String}
Name of your global component.
Default: PerfectScrollbar
tag {String}
Tag which will be render as perfect scrollbar container
Default: div
watchOptions {Boolean}
Set true if you want to update perfect-scrollbar on options change
Default: false
options {Object}
: Optionsperfect-scrollbar options.
Default: {}
<template>
<div>
<perfect-scrollbar>
<p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
</perfect-scrollbar>
</div>
</template>
<script>
import { PerfectScrollbar } from 'vue2-perfect-scrollbar'
export default {
components: {
PerfectScrollbar
}
}
</script>
<style src="vue2-perfect-scrollbar/dist/vue2-perfect-scrollbar.css"/>
tag {String}
Tag which will be render as perfect scrollbar container
Default: div
watchOptions {Boolean}
Set true if you want to update perfect-scrollbar on options change
Default: false
options {Object}
: Optionsperfect-scrollbar options.
You can use Vue.js way to listen on the all perfect-scrollbar events. List of events you can find here
Simple example:
<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>
https://mercs600.github.io/vue2-perfect-scrollbar/. You can also fork example from codesandbox
One of simple solution to setup custom scrollbar to top when your route is changed.
<perfect-scrollbar ref="scroll">
<router-view></router-view>
</perfect-scrollbar>
watch: {
$route() {
this.$refs.scroll.$el.scrollTop = 0;
}
}
FAQs
Vue.js wrapper for perfect scrollbar
The npm package vue2-perfect-scrollbar receives a total of 14,337 weekly downloads. As such, vue2-perfect-scrollbar popularity was classified as popular.
We found that vue2-perfect-scrollbar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.