GithubHelp home page GithubHelp logo

connoratherton / loaders.css Goto Github PK

View Code? Open in Web Editor NEW
10.2K 291.0 1.3K 328 KB

Delightful, performance-focused pure css loading animations.

Home Page: https://connoratherton.com/loaders

CSS 96.96% JavaScript 1.59% CoffeeScript 1.45%

loaders.css's Introduction

Loaders.css

Delightful and performance-focused pure css loading animations.

What is this?

See the demo

A collection of loading animations written entirely in css. Each animation is limited to a small subset of css properties in order to avoid expensive painting and layout calculations.

I've posted links below to some fantastic articles that go into this in a lot more detail.

Install

bower install loaders.css
npm i --save loaders.css

Usage

Standard
  • Include loaders.min.css
  • Create an element and add the animation class (e.g. <div class="loader-inner ball-pulse"></div>)
  • Insert the appropriate number of <div>s into that element
jQuery (optional)
  • Include loaders.min.css, jQuery, and loaders.css.js
  • Create an element and add the animation class (e.g. <div class="loader-inner ball-pulse"></div>)
  • loaders.js is a simple helper to inject the correct number of div elements for each animation
  • To initialise loaders that are added after page load select the div and call loaders on them (e.g. $('.loader-inner').loaders())
  • Enjoy

Customising

Changing the background color

Add styles to the correct child div elements

.ball-grid-pulse > div {
  background-color: orange;
}
Changing the loader size

Use a 2D Scale transform

.loader-small .loader-inner {
  transform: scale(0.5, 0.5);
}

Browser support

Check the can I use tables. All recent versions of the major browsers are supported and it has support back to IE9.

Note: The loaders aren't run through autoprefixer, see this issue.

IE 11 Firefox 36 Chrome 41 Safari 8

Contributing

Pull requests are welcome! Create another file in src/animations and load it in src/loader.scss.

In a separate tab run gulp --require coffee-script/register. Open demo/demo.html in a browser to see your animation running.

Further research

Inspired by loaders.css

A few other folks have taken loaders and ported them elsewhere.

Licence

The MIT License (MIT)

Copyright (c) 2016 Connor Atherton

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

loaders.css's People

Contributors

auspexeu avatar caiovaccaro avatar chrisvmiller avatar connoratherton avatar dimargb avatar gianjohansen avatar hokid avatar ilanfrumer avatar jayin avatar jonjaques avatar kaermorchen avatar kkirsche avatar kscons avatar kvnneff avatar markdalgleish avatar masadow avatar mixxorz avatar nikolas avatar octycs avatar shovon avatar silvenon avatar superelement avatar zalog 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

loaders.css's Issues

No animations

I am using this react loaders and there is no animation just static circles?

Animation declaration dropped by Firefox

Firefox can't parse this (example):
animation: line-scale-pulse-out-rapid 0.9s 0 infinite cubic-bezier(.11,.49,.38,.78);

After changing it to
animation: line-scale-pulse-out-rapid 0.9s 0s infinite cubic-bezier(.11,.49,.38,.78);
it works.

Documentation on what browsers this supports

I know i can dig into the code and use caniuse.com to figure this one out but I'm wondering if you know off hand what browsers this supports?

If so then it would be awesome if you could throw a table into the Readme for quick reference.

If not then just let me know and I'll jump in and cross reference with caniuse.com and maybe create a PR with the compatibility table 😉

Wrong file name for ball-triangle-path

For the animation ball-triangle-path the scss file is named as src/animations/ball-triangle-trace.scss I think it would be nice to have consistent naming so upstream libs using this doesnt break when fetching files by animation name

Are there any rules?

I would like to contribute to the increase in the concentration of load animation, what are the considerations?

Name of the specific loader?

How to know the name of the specific loader?
Neither mentioned on the website nor in the README.

It will be good to see the names of the loaders on the website (maybe on hover).
Correct me if I am wrong.

Changing colors

Hi Connor,

Thank you for building this fantastic library, I've had a lot of fun incorporating it into my application. Connor I wanted to ask you how we can change the color of the loaders. I've actually gone to the trouble of changing the code in the loaders.min.css file to .ball-pulse-sync>div,.ball-pulse>div{width:15px;height:15px;margin:2px;display:inline-block}.ball-pulse-sync>div,.ball-pulse>div,.ball-scale>div{background-color:#2F2F2F;border-radius:100%}@-webkit-keyframes scale{0%,80%{-webkit-transform:scale(1);transform:scale(1);opacity:1}45%{-webkit-transform:scale(.1);transform:scale(.1);opacity:.7}}@keyframes. The background color by default is #fff (white) I believe. This has worked when I am running the react application in the dev environment locally, however, once my application codebase is minified with webpack and deployed, this is not working. Any ideas why? Is there another way for us to make css changes to the loaders.min.css file?

Thank you,

How to scale the loader's size? Here is the right code

css
.loader-small .loader-inner { transform: scale(0.5, 0.5); }

HTML
<div class="loader-small"> <div class="loader-inner ball-pulse"> <div></div> <div></div> <div></div> </div><span class="tooltip"> <p>ball-pulse</p></span> </div>

Remove prefixing

Everyone could/should be using Autoprefixer (or some similar/lesser tool) in their development environment. It's usually a bad practice to have prefixing in libraries.

Small/Large sizing classes

Hello, thanks for putting this together - Looks great so far!

Do you see utility in adding some sizing classes? Most of these are appropriate for loading panes or pages currently, but some might work well inside a button or other UI elements.

I'm currently wrapping a React component around this (props for active, type) and a sizing option would be great too. I'll see if I can get to a PR tonight but just wanted to get your thoughts.

No license?

There is no licensing information anywhere in the repository or README file.

Suggestion

Add a loading animation similar to the one used by rollage, the source code for which is here.

Cannot read property 'fn' of undefined

Looks like this is failing because it wants JQuery that I don't have. However, $ is defined because chrome defines it if you are not using JQuery.

  $.fn.loaders = function() {
    return this.each(function() {
      var elem = $(this);
      $.each(divs, function(key, value) {
        if (elem.hasClass(key))
          elem.html(addDivs(value))
      })
    });
  };

about creating a Meteor package

hi, i download your source code, and made a meteor package with it,
because there is no an official one,
and i believe many developers will love it ,
if you are not willing to see that, i will remove it !
and i promise i will update it when you publish a new version.
thanks for your hard work.

Possible to change speed?

These are beyond incredible. Is there currently a way to access the speed of the loading animation (slower/faster transitions between a given loader's various states)?

Add LICENSE file to repo

People usually look for this rather than at the bottom of your README for a license. Here's the content of a standard Github MIT LICENSE file:

The MIT License (MIT)

Copyright (c) 2015 Connor Atherton

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

What is .scss-lint.yml

Should that be in the repo if it's a development thing? If it's necessary (and not just a convenience thing) then could it go into src?

Build is non-deterministic, CSS changes on every build

The random animation delays (e.g.

animation-delay: ((random(100) / 100) - 0.2) + s;
animation-duration: ((random(100) / 100) + 0.3) + s;
) are only calculated at build time and make the build non-deterministic.

Every build results in a different CSS file, which is probably not ideal for a number of reasons:

  • A refactor with no change to the resulting CSS will still generate new animations.
  • Random animations are locked for each version, so users of an app using this library will see the same "random" animation for a while until they upgrade, at which point they'll get a new "random" animation until the next upgrade.

If you don't see this as a problem, feel free to close this issue.

benchmarks

The description says emphasis is on performance, but how does this compare to other libraries (animate-css/animate.css@c0abb26) or just an animated gif loader? Both CSS transitions and animated GIF loaders are blocked by JavaScript, but is there some other performance gain from using CSS transition loaders?

Put demo in gh-pages

Then you can link to a live demo, and in the README link to the gh-pages branch for people who want to look at the code.

This will keep your repo neater.

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.