GithubHelp home page GithubHelp logo

Comments (5)

siddii avatar siddii commented on June 3, 2024

I understand the need here. However, its a very thin line on deciding where this method can go. We can argue that the callee should be able to do this from its end or probably the concern of directive itself.

I am thinking out loud in a broader term here.. may be the best thing to do is probably make it generic, like adding methods on other attributes as well like.. resetInterval(intervalTime), resetCountdown(countdown), resetStartTime(startTime) etc.
Those methods can reset the value & timers also.
Let me know what you think.

from angular-timer.

SaulBurgos avatar SaulBurgos commented on June 3, 2024

I hadn't thought in the others methods,that will be useful too , I like your idea :)

from angular-timer.

SargoDarya avatar SargoDarya commented on June 3, 2024

+1

Any news on this?

from angular-timer.

siddii avatar siddii commented on June 3, 2024

Sorry I haven't had a chance to look at this. I will take a look at this as my next thing as soon as possible.

from angular-timer.

sadlerw avatar sadlerw commented on June 3, 2024

The code to subtract seconds from the startTime is pretty simple. I managed to create a "count up" timer by just adding an attribute similar to countdown and then:

      $scope.addCUSeconds = $element[0].addCUSeconds = function(millisToRemove){
        $scope.startTime = new Date($scope.startTime.getTime() - millisToRemove)
        $scope.$digest();
        if (!$scope.isRunning) {
          $scope.start();
        }
      };
      $scope.$on('timer-set-cu-seconds', function (e, millis) {
        $timeout(function (){
          $scope.addCUSeconds(millis);
        });
      });

Naming could probably be improved. The big problem I see is that because you are using controller rather than link (postlink) you can't have something like:

timer(start-time="{{myStartTime}}", auto-start="false", interval='1000') {{mminutes}}:{{sseconds}}

I tried messing around with changing start-time to & or @ scoping, but the init of startTime in $scope.start() pretty much kills it.

from angular-timer.

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.