Simple And Lightweight “back to top” Vue.js Component

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.

Must Read: Back to Top Button Using Vanilla Javascript | back2top.js

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

Must Read: A Smooth Scrolling Back To Top Button on Native JavaScript | up-button

PropertyTypeDefault ValueDescription
textString‘Back to top’Button description.
visibleYNumber400Show button when scrollY equals visibleY value.
durationNumber800Scrolling animation duration.

Events

Must Read: [TypeWatch] jQuery Plugin to Determine When a User Stops Typing in a Text Field

NameDescription
scrolledOnTopTriggered when scrolling finished (can be used to refresh content)

See Also –

Fixed Table Header To The Top Of Page On Scroll in Pure Javascript
Hide On Scroll Fixed Top Navigation In Pure JavaScript (no jQuery)
JavaScript Library To Create Sticky Header & Footer On Scroll | titleBarJs


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.

Related Posts

Bootstrap-Fileinput

HTML 5 File Input Optimized for Bootstrap 4.x./3.x with File Preview | Bootstrap Fileinput

bootstrap-fileinput is an improved HTML 5 file input  Bootstrap 5.x, 4.x and 3.x with file preview for different files, provides multiple selections, resumable section uploads, and more….

Floating-Whatsapp-Chat-Button

How to Add Floating Whatsapp Chat Button In HTML | venom-button

Venom Button is a very simple plugin for the jQuery floating WhatsApp button. Adds a floating button to your site that calls WhatsApp Click to Chat API. It will automatically start the WhatsApp…

Data-Table-Generator-Tabulator

Interactive Data Table Generator with JS/jQuery and JSON | Tabulator

Tabulator allows you to create interactive tables in seconds from any HTML Table, JavaScript array, AJAX data source, or JSON format data. Just include the library in your…

alert-confirm-prompt-attention-js

Simple Alert, Confirm, Prompt Popup Using Vanilla JavaScript Library | attention.js

JavaScript provides various built-in functionality to display popup messages for different purposes. Attention JS is a vanillaJS plugin used to create a custom alert, confirm, or Prompt…

Bootstrap-4-Toast-Notification-Plugin

Lightweight Bootstrap 4 Toast Notification Plugin | BS4 Advanced Toast

A lightweight Bootstrap 4 Toast Notification plugin integrated with JS/jQuery. bs4-toast.js is a JavaScript library that enhances the native Bootstrap toast component with icons, buttons, callbacks, and…

Audio-Visualizations-Wave

How to Create Audio Visualizations with JavaScript | Wave.js

Audio Visualizer Library – wave.js is a vanilla javascript audio visualization library that provides 20+ creative audio visualization effects to bring more engagement to your visitor. Contribute…

Leave a Reply

Your email address will not be published. Required fields are marked *