Giter Site home page Giter Site logo

Comments (3)

dasois avatar dasois commented on July 30, 2024

i guess then your suggestion is, that a call of start() should implicitly call stop()? Or should it throw an error if a timer is already started?

from ngprogress.

martiro avatar martiro commented on July 30, 2024

CHANGE1: In the start method I make a check of intervalCounterId variable:
start: function () {
// TODO Use requestAnimationFrame instead of setInterval
// https://developer.mozilla.org/en-US/docs/Web/API/window.requestAnimationFrame
this.show();
var self = this;
// RBM call setInterval only if it ha never been called
if (intervalCounterId == undefined) {
intervalCounterId = setInterval(function () {
if (isNaN(count)) {
clearInterval(intervalCounterId);
count = 0;
self.hide();
} else {

CHANGE2: in the reset function i reset the value of intervalCounterId to undefined

reset: function () {
//logger.debug("ngProgress.reset() count=" + count);
clearInterval(intervalCounterId);
intervalCounterId = undefined;
count = 0;
this.updateCount(count);
return 0;
},

CHANGE3: in the nested timeout I simply call the reset method

complete: function () {
//logger.debug("ngProgress.complete() count=" + count);
count = 100;
this.updateCount(count);
var self = this;
$timeout(function () {
self.hide();
$timeout(function () {
//count = 0;
//self.updateCount(count);
self.reset(count);
}, 500);
}, 1000);
return count;
}

Bye

from ngprogress.

zackarychapple avatar zackarychapple commented on July 30, 2024

+1 I would really like if this would be resolved.

from ngprogress.

Related Issues (20)

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.