GithubHelp home page GithubHelp logo

jorisnoo / htmx-progress Goto Github PK

View Code? Open in Web Editor NEW

This project forked from swup/progress-plugin

0.0 0.0 0.0 283 KB

⏳ Htmx extension for displaying a loading indicator

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

License: MIT License

JavaScript 100.00%

htmx-progress's Introduction

Swup Progress Bar Plugin

This swup plugin will display a progress bar for all requests taking longer than ~300ms.

Installation

This plugin can be installed with npm

npm install @swup/progress-plugin

and included with import

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

or included from the dist folder

<script src="./dist/SwupProgressPlugin.js"></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,
  hideImmediately: true
}

className

Class name to use for the container div.

transition

Length of 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.

hideImmediately

Whether the progress bar is hidden instantly after a page visit.

Set to false to always complete the transition to width: 100% before hiding it.

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.