Code Monkey home page Code Monkey logo

vue-scroll-up's Introduction

vue-scroll-up

vue3 npm Version npm npm

Scroll up component for Vue 3.

Installation

Get from npm / yarn:

npm i vue-scroll-up@next
yarn add vue-scroll-up@next

๐Ÿ‘‰ Vue 2 version check here

Usage

Use inside your app:

import VueScrollUp from 'vue-scroll-up'

export default {
  components: {
    VueScrollUp,
  }
}

Or

import VueScrollUp from 'vue-scroll-up'

const app = createApp({});

app.component(VueScrollUp.name, VueScrollUp);
HTML
<vue-scroll-up 
  tag="div"
  custom-class="vue-scroll-up"
  :scroll-duration="1000"
  :scroll-y="250"
  :always-show="false"
/>
Use Slot
<vue-scroll-up
  v-slot="{ isTop }"
  :always-show="true"
>
  {{ isTop ? '๐Ÿ‘‡' : '๐Ÿ‘†' }}
</vue-scroll-up>

<vue-scroll-up
  v-slot="{ pointer }"
  :always-show="true"
>
  {{ pointer }}
</vue-scroll-up>
Design your scroll button ๐Ÿ‘‰ See example here

  1. Add your custom class name
<vue-scroll-up custom-class="my-scroll-up" />
  1. Add CSS
.my-scroll-up {
  align-items: center;
  background-color: rgba(0, 0, 0, 0.658);
  border: rgba(0, 0, 0, 0.658);
  border-radius: 100px;
  bottom: 100px;
  color: white;
  cursor: pointer;
  display: flex;
  height: 55px;
  justify-content: center;
  position: fixed;
  right: 10px;
  width: 55px;
  z-index: 99;
}

.my-scroll-up::after {
  border: 2px solid white;
  border-radius: 10px;
  content: '';
  display: block;
  height: 25px;
  margin: 0 auto;
  width: 10px;
}

.my-scroll-up::before {
  animation: 2s top infinite;
  border: 1px solid white;
  border-radius: 10px;
  content: '';
  display: block;
  height: 10px;
  left: 49%;
  position: absolute;
  width: 0;
}

@keyframes top {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@media screen and (max-width: 450px) {
  .vue-scroll-up {
    bottom: 10px;
    transform: translateX(5px) scale(0.7);
  }
}

Attributes

Parameter Type Defaults Description
tag string span Default render element.
custom-class string vue-scroll-up Custom your class name.
scroll-duration number 200 Page to top speed.
scroll-y number 250 Show button when scrollY equals a number.
always-show boolean false Always show button even scroll to top.

Slot

Name Description
isTop Scroll button is top.
pointer Value of scroll y.

vue-scroll-up's People

Contributors

dependabot[bot] avatar keithmclaughlin avatar runkids avatar slaweet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vue-scroll-up's Issues

Add more props?

It would be nice to have more props available:

  • position right & bottom
  • background color
  • change icon/text

Vue.js 3 support

As title, is it possible to support the Vue.js 3 version?

Thanks.

Infinite scroll up and down (with `:root { scroll-behavior: smooth }` css)

Expected behaviour

Clicking the scroll top button scrolls up

Actual behaviour

Clicking the scroll top button scrolls up and down infinitelly
dodgy-scroll-to-top

Environment Info:

System:
OS: Linux 5.4 Ubuntu 18.04.5 LTS (Bionic Beaver)
CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
Binaries:
Node: 16.4.0 - ~/.nvm/versions/node/v16.4.0/bin/node
Yarn: 1.22.5 - ~/.yarn/bin/yarn
npm: 7.18.1 - ~/.nvm/versions/node/v16.4.0/bin/npm
Browsers:
Firefox: 91.0
npmPackages:
ts-vue-plugin: 0.1.3 => 0.1.3
typescript: 4.3.5 => 4.3.5
vue: 2.6.14 => 2.6.14
vue-scroll-up: 1.0.3 => 1.0.3
bootstrap: 5.1.0 => 5.1.0
bootstrap-vue: 2.21.2 => 2.21.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.