Giter Club home page Giter Club logo

angularjs-spinner's People

Contributors

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

Watchers

 avatar  avatar  avatar  avatar  avatar

angularjs-spinner's Issues

Multiple instances of loading spinner possible?

I have some complex pages where I'm looking to apply spinners to multiple nested views. Is there a way to accomplish this with the angularjs-spinner? So far, what I'm seeing is each spinner instance fires on every request. I was hoping to tie it to individual scopes, but not sure how :P

Samples do not work

Hi,

cloned the repo, ran the sample01 - and it doesn't work.
The event is never caught in the directive.

Thanks.

broadcast is slow on apps of moderate size

In your pub/sub model you are broadcasting on the root scope, which bubbles down through every scope in the app (it's easy to have hundreds) looking for listeners.

You can achieve the same architecture with much better performance by using $rootScope.emit(...) rather than $rootScope.broadcast(....) On the listening side you'll need to change $scope.on(...) to $rootScope.on(...)

In my app the performance different was fairly huge in UI responsiveness, to the extent that I couldn't achieve my design until I made this modification.

See here for an explanation of avoiding .broadcast: http://stackoverflow.com/a/19498009/288703

and here for some quantification of the performance difference:

http://jsperf.com/rootscope-emit-vs-rootscope-broadcast

DOM manipulation in responseInterceptor

Thanks for the article.. was going to leave a comment there, but saw the link to the GitHub code.

I would recommend that you rework the DOM manipulation in your responseInterceptor code here:
https://github.com/lavinjj/angularjs-spinner/blob/master/app/app/app.js#L30

As a general rule, Angular code should only perform DOM work inside of directives.

Instead of hard-coding the element in there, you can broadcast an event like this:

$rootScope.$broadcast('event:httpRequestStarted');

$rootScope.$broadcast('event:httpRequestCompleted');

Then inside of the controller you can set a property on the $scope based on the event.

// default to showing
$scope.loadingVisible = true;

$scope.$on('event:httpRequestStarted', function() {
  $scope.loadingVisible = true;
});

$scope.$on('event:httpRequestCompleted', function() {
  $scope.loadingVisible = true;
});

In the markup, you can use the ngShow directive on your element
https://github.com/lavinjj/angularjs-spinner/blob/master/app/index.html#L25

So you would no longer need an id, and your markup would use your scope value to toggle its visibility:

 <div ngShow="loadingVisible" class="row-fluid ui-corner-all" style="padding: 0 .7em; display: none;">

Thanks for the inspiration!

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.