Vue.js is a simple and lightweight component that scrolls up smoothly when clicked. It can also be used to update the data to load the latest content using the scrolledOnTop event.
Inspired by Instagram, Linkedin, Reddit, etc., scroll to the refresh button.
vuejs scroll to top, scroll to top javascript, scroll to top button js, animated scroll to top button, back to top button html, scroll to top button vue js
A Lightweight Animate Plugin Scrolling to Top of the Page | Vanillatop
How to make use of it:
Install and download:
npm i vue-simple-scroll-up --save
1. Import for global use.
import Vue from 'vue' import scrollUp from 'vue-simple-scroll-up' Vue.use(scrollUp) ...
2. or on a single component.
import scrollUp from 'vue-simple-scroll-up' ... }, components: { 'vue-scroll-to-top': scrollUp } ...
3. Add this to your files:
<vue-scroll-to-top text="Back to top" :visibleY="1200" :duration="1000"></vue-scroll-to-top>
4. To run the scrolledOnTop event:
<vue-scroll-to-top text="Back to top" @scrolledOnTop="yourReloadFunction()"></vue-scroll-to-top>
5. Replace CSS property to change button style:
.vue-scroll-button{ background-color: #4CAF50; /* button background color */ color: white; /* button text color */ } .vue-scroll-button:hover{ box-shadow: 0 12px 14px -6px #4CAF50; /* button shadow */ }
Props
Property | Type | Default Value | Description |
---|---|---|---|
text | String | ‘Back to top’ | Button description. |
visibleY | Number | 400 | Show button when scrollY equals to visibleY value. |
duration | Number | 800 | Scrolling animation duration. |
Events
Name | Description |
---|---|
scrolledOnTop | Triggered when scrolling finished (can be used to refresh content) |
Simple Scroll To Top Component Plugin/Github
See Demo And Download
Official Website(asdf1899): Click Here
This superior jQuery/javascript plugin is developed by asdf1899. For extra advanced usage, please go to the official website.
Be First to Comment