Coder Social home page Coder Social logo

swup / progress-plugin Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 5.0 707 KB

A swup plugin for displaying a progress bar ⏳

Home Page: https://swup.js.org/plugins/progress-plugin

License: MIT License

TypeScript 100.00%
swup progress-bar loading-indicator plugin page-transitions

progress-plugin's Introduction

Swup Progress Bar Plugin

A swup plugin for displaying a progress bar.

Shows a loading indicator for requests taking longer than ~300ms.

Installation

Install the plugin from npm and import it into your bundle.

npm install @swup/progress-plugin
import SwupProgressPlugin from '@swup/progress-plugin';

Or include the minified production file from a CDN:

<script src="https://unpkg.com/@swup/progress-plugin@3"></script>

Usage

To run this plugin, include an instance in the swup options.

const swup = new Swup({
  plugins: [new SwupProgressPlugin()]
});

Styling

The progress bar has a class name of swup-progress-bar you can use for styling.

.swup-progress-bar {
  height: 4px;
  background-color: blue;
}

Options

{
  className: 'swup-progress-bar',
  transition: 300,
  delay: 300,
  initialValue: 0.25,
  finishAnimation: true
}

className

Class name to use for the container div.

transition

Length of the CSS transition between loading states, in milliseconds.

delay

How long to wait before showing the progress bar, in milliseconds.

Set to 0 to always display the progress bar, even on fast requests.

initialValue

To create a slightly more "realistic" appearance, the progress bar will start out at a random position beteen 0 and the value of this option. Set to 0 to always start from the left.

finishAnimation

Whether the progress bar will complete the transition to 100% before hiding.

progress-plugin's People

Contributors

daun avatar dependabot[bot] avatar gmrchk avatar hirasso avatar ssense1337 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

progress-plugin's Issues

Conflict with SwupHeadPlugin

Hi,

I think there is a conflict with SwupHeadPlugin.
The progress bar never reach the right of the page.

To fix the issue i changed :

	document.documentElement.insertBefore(this.progressElement, document.body);

into

	document.documentElement.prepend(this.progressElement, document.body);

But maybe you would think about another solution with better support.

Thanks

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.