Giter Club home page Giter Club logo

vue-scroll-progress-bar's Introduction

vue-scroll-progress-bar

Donate Netlify Status

Getting started

Install

$ npm install @guillaumebriday/vue-scroll-progress-bar --save

or

$ yarn add @guillaumebriday/vue-scroll-progress-bar

Install the plugin into Vue:

import Vue from 'vue'
import VueScrollProgressBar from '@guillaumebriday/vue-scroll-progress-bar'

Vue.use(VueScrollProgressBar)

Or use the component directly:

import { VueScrollProgressBar } from '@guillaumebriday/vue-scroll-progress-bar'

export default {
  components: {
    VueScrollProgressBar
  },

  // ...
}

Basic Usage

<template>
  <vue-scroll-progress-bar @complete="handleComplete" height="2rem" />
</template>

Props

key description default
height Height of the progress bar '.5rem'
backgroundColor Background property of the progress bar 'linear-gradient(to right, #38C172, #51D88A)'
barClass Class attribute of the progress bar '{}'
containerColor Background property of the progress bar container 'transparent'
zIndex z-index property of the progress bar container '50'
containerClass Class attribute of the progress bar container '{"progress-bar-container--container": true}'

With :

.progress-bar-container--container {
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
}

containerClass must be used to override the .progress-bar-container--container default class. You can use the default :class syntax on the component to add classes if needed.

Events

key description
begin When scroll reached 0%
complete When scroll reached 100%

Develop

Project setup

$ yarn install
$ yarn build

Open example app

$ cd example
$ yarn
$ yarn serve

Lint files

$ yarn lint

Contributing

Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.

License

This project is released under the MIT license.

vue-scroll-progress-bar's People

Contributors

dependabot[bot] avatar guillaumebriday avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vue-scroll-progress-bar's Issues

new functionality - DOM selector handler

Hello,
I really like your plugin, however I would like to ask you to add new functionality.
Could you add the option of adding a handler on a given DOM element? I would like to use your plugin on the blog, and the scrollbar position to refer to the article text, but when the page has article, sidebar and footer then the scrollbar measures the entire page, not what the user is interested in - the length of the article. For e.g.

<vue-scroll-progress-bar handler=".post-article" @complete="handleComplete" height="2rem" />

I think this is a nice option.
Hold on!

Allow custom vertical offset of progress bar

In certain situations, there may be a large header or other element that you would want to exclude from the height calculation. I'd like to be able to pass a reference to an element and have the progress bar calculate it's width and only become visible after that referenced element is outside of the viewport.

Will submit a PR for this soon.

Improve performance with passive

Another thing that I notice. You could use { passive: true } for the addEventListener for scroll.
This improves performance!

Here for example https://stackoverflow.com/questions/37721782/what-are-passive-event-listeners

Here is the code if the browser supports passive:

let supportsPassive = false;
try {
    const opts = Object.defineProperty({}, 'passive', {
        // eslint-disable-next-line
        get() {
            supportsPassive = true;
        },
    });

    window.addEventListener('testPassive', null, opts);
    window.removeEventListener('testPassive', null, opts);
} catch (e) {
    // nothing
}

and then for example:

window.addEventListener('scroll', _.debounce(this.calculatesomething, 50), supportsPassive ? { passive: true } : false);

Component not rendering correctly on production build

Hi Gaillaume,

Thank you for your plugin. It's working great on my Nuxt 2 website in development mode, but I am encountering difficulties in production mode. I've just added a question on Stackoverflow, since I am not entirely sure if the problem lies in my Nuxt installation or the package itself.

https://stackoverflow.com/questions/77805521/component-output-renders-incorrectly-after-running-nuxt-production-build

I am at a loss here, hoping you can point me to the right direction for a solution. I can share the production URL with you if you like.

Screenshot 2024-01-12 at 10 16 24 Screenshot 2024-01-12 at 10 14 03

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.