Giter Club home page Giter Club logo

ngactivityindicator's Introduction

ngActivityIndicator

Simple application preloader animation provider for Angular.js applications.

ngActivityIndicator is small, all-in-one solution, customizable through themes and dependant only on Angular.js.

Install

You can download all necessary ngActivityIndicator files manually or install it with bower:

bower install ngActivityIndicator

Usage

You need to include ngActivityIndicator.js and ngActivityIndicator.css (as minimal setup) to your project and then you can start using $activityIndicator service wherever you want - inside your directives, controllers or services. For example in controllers:

var app = angular.module('exampleApp', ['ngActivityIndicator']);

app.controller('MainCtrl', ['$activityIndicator', '$timeout',
	function ($activityIndicator, $timeout) {
		$activityIndicator.startAnimating();
		$timeout(function () {
			$activityIndicator.stopAnimating();
		}, 3000);
	}
]);

You can use ngActivityIndicator directive to show one of built-in animated views or you are able to create your own preloader in html, style it with CSS and simply show/hide it:

<body>
	<div ng-show="AILoading" class="your-preloader"></div>
	<div ng-hide="AILoading" ng-view></div>
</body>

Also this service can be easily used with loading SVG concept by Brett Jackson. But be aware of limited browser SVG support and user experience issues with perceptual loading time - http://caniuse.com/svg-smil.

Or you can use preloader styles from Luke's https://github.com/lukehaas/css-loaders as well.

API

API is highly inspired by Objective-C UIActivityIndicatorView class from UIKit framework.

startAnimating()

Start preload animation by setting $rootScope.AILoading to true.

stopAnimating(delay)

Stop animating preloader by setting $rootScope.AILoading to false.

isAnimating()

Check whether activity indicator is animating or not.

setActivityIndicatorStyle()

There are several styles built-in. Style by default is CircledGrey, you can change it by setting the value string on $activityIndicatorProvider, example:

angular.module('yourModule', ['ngActivityIndicator'])
	.config(['$activityIndicatorProvider', function ($activityIndicatorProvider) {
		$activityIndicatorProvider.setActivityIndicatorStyle('SpinnerDark');
	}]);

Directive

Module is shiped with helpful directive. It is called as ngActivityIndicator and can behave differently based on the tag or restrict it's used with.

When it's added to <body> tag, it adds relevant preloader into the app, shows and hides ng-view while animating. It's recommended and the most common use-case, example:

<!-- Indicator is injected into the DOM automatically -->
<body ng-activity-indicator>

	<!-- ngView is shown/hidden automatically -->
	<div ng-view></div>
</body>

If you prefer to manage what to show on preloading mode by yourself, just use it as an element or attribute. Directive will handle animation status automaticly, example:

<body>
	<!-- it is shown/hidden automatically -->
	<div ng-activity-indicator class="center"></div>

	<!-- show/hide elements based on $rootScope.AILoading property -->
	<div ng-hide="AILoading" class="some-wrapper"></div>
</body>

You can also override preloader style by adding it's name as directive value:

<div ng-activity-indicator="CircledDark"></div>

Skip ngShow

Sometimes it's useful to control indicator show/hide behavior by your own $scope (for example if you have multiple loaders inside one view). In this case there is additional attribute for directive:

skip-ng-show="[yes/no]"

It's easy to use, just add it on the activity indicator directive:

<div ng-show="myLoadingConditional" ng-activity-indicator skip-ng-show="yes"></div>

This will ends up in skipping ng-show="AILoading" directive on ngActivityIndicator element and will add ability to control loader presence by myLoadingConditional.

Built-in styles

You're able to choose what indicator suites you most within default ones or create your own.

List of style names:
  • CircledWhite / CircledGrey (default) / CircledDark
  • DottedWhite / DottedGrey / DottedDark
  • SpinnerWhite / SpinnerGrey / SpinnerDark

Contribution

Want to add your styles into this module? Cool, just fork this repo and make pull-request!

License

WWWWWW||WWWWWW
 W W W||W W W
      ||
    ( OO )__________
     /  |           \
    /o o|    MIT     \
    \___/||_||__||_|| *
         || ||  || ||
        _||_|| _||_||
       (__|__|(__|__|

MIT Licensed

Copyright (c) 2014, Dmitri Voronianski [email protected]

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.

ngactivityindicator's People

Contributors

alevinval avatar alexbeletsky avatar anton-107 avatar nikhildev avatar voronianski 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

ngactivityindicator's Issues

Demo: first two don't animate

The first two example loaders in the demo don't actually animate. The Start button doesn't do anything (I'd expect it to make them start). The third one is spinning normally.

I'm sure this has technically nothing to do with the plugin, but I guess for a demo it still needs to work to show off the eyecandy.

This is on Windows 7 + Opera 12.17 (latest).

Backdrop for loading indicator

Is it possible to have a backdrop behind the indicator that would block the page? I have tried modifying the CSS, but have not been able to get it to work.
2014-12-b0f9u

Does it support ui-view?

I'm trying to make it work using uiRouter (ui-view) but i can't get it working. Does this have any special way to make it work with ui-view?

Does not works in IE

sample project also does not works in IE(version 11) when clicking on start button it opens the openfile window of that project

Question : cursor

Hello,
Is it possible to replace the cursor with this animation with AngularJS ?
Thanks for the repo !

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.