Skip to content

Commit

Permalink
Merge pull request #3 from rochaporto/pause
Browse files Browse the repository at this point in the history
Add swiss railway clock pause
  • Loading branch information
wout authored Jan 13, 2018
2 parents 53cb0aa + ce3a379 commit de70d67
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

<script src="lib/svg.min.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/svg.easing.min.js" type="text/javascript" charset="utf-8"></script>
<script src="svg.clock.min.js" type="text/javascript" charset="utf-8"></script>
<script src="svg.clock.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
SVG('canvas').clock('100%').start()
</script>

</html>
</html>
18 changes: 11 additions & 7 deletions svg.clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ SVG.extend(SVG.Clock, {

/* ensure duration */
if (duration == null)
duration = 300
duration = 1000

/* set all pointers */
this
.setHours(time.getHours(), time.getMinutes())
.setMinutes(time.getMinutes(), duration)
.setSeconds(time.getSeconds(), duration)
.setSeconds(time.getSeconds(), duration, true)

return this
}
Expand Down Expand Up @@ -165,28 +165,32 @@ SVG.extend(SVG.Clock, {
return this
}
// Set second
, setSeconds: function(seconds, duration) {
, setSeconds: function(seconds, duration, pause) {
/* store seconds */
this.time.seconds = seconds

/* register a full circle */
if (seconds == 0)
if (pause && seconds>=59) {
this.full.seconds++

seconds = 0
} else if (pause) {
seconds = this.time.seconds * (60/58.0)
}

/* calculate rotation */
var deg = this.full.seconds * 360 + 360 / 60 * seconds

/* animate if duration is given */
if (duration)
this.seconds
.animate(duration, SVG.easing.elastic)
.animate(duration, this.linear)
.rotate(deg, 50, 50)
else
this.seconds
.rotate(deg, 50, 50)

return this
}
, linear: function(pos) { return pos }

})

Expand Down

0 comments on commit de70d67

Please sign in to comment.