1.6.1 • Published 5 years ago

vue-backtotop v1.6.1

Weekly downloads
4,700
License
-
Repository
github
Last release
5 years ago

Vue Backtotop Component

npm

A Back-to-top component for Vue.js, which scroll page to the top when clicked

Demo

See demo.

Install via npm

npm install vue-backtotop --save

Import and use

Import for global usage

import Vue from 'vue'
import BackToTop from 'vue-backtotop'

Vue.use(BackToTop)
...

Or on a single component

import BackToTop from 'vue-backtotop'
...
},
components: { BackToTop }
...

Props

NameTypeDefaultDescription
textString'Voltar ao topoText of back to top button
visibleoffsetString or Number600Where the component should visible when user scroll reach certain offset
visibleoffsetbottomString or Number0Where the component should visible when user scroll reach certain bottom offset
bottomString40pxBottom position of the component
rightString30pxRight position of the component
scrollFn (eventObject)Function30pxFunction defining custom actions when scrolling

Events

NameDescription
scrolledFired when page's scroll ends

How to use

Currently, the vue-backtotop has a property named "text", that is the text which will be visible on button. The default value is "Voltar ao topo".

<back-to-top text="Back to top"></back-to-top>

The button to back to top become visible at window scroll at 600 > px. If you want to change this value, pass a property named "visibleOffset" with a number value.

<back-to-top text="Back to top" visibleoffset="500"></back-to-top>

You can also know when scroll ends

<back-to-top text="Back to top" @scrolled="myFunction"></back-to-top>

Now, it's possible to use your own html/vue component inside vue-backtotop component

<!-- in your template -->
<back-to-top bottom="50px" right="50px">
  <button type="button" class="btn btn-info btn-to-top"><i class="fa fa-chevron-up"></i></button>
</back-to-top>
/* in your css */
.btn-to-top {
  width: 60px;
  height: 60px;
  padding: 10px 16px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 22px;
}
1.6.1

5 years ago

1.6.0

5 years ago

1.4.12

6 years ago

1.3.12

6 years ago

1.3.11

6 years ago

1.3.10

6 years ago

1.3.9

6 years ago

1.3.8

6 years ago

1.2.8

6 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago