Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-countdown-clock

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-countdown-clock - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

npm-shrinkwrap.json

121

build/react-countdown-clock.js

@@ -55,20 +55,14 @@ (function webpackUniversalModuleDefinition(root, factory) {

/* 0 */
/*!**************************************!*\
!*** ./react-countdown-clock.coffee ***!
\**************************************/
/***/ function(module, exports, __webpack_require__) {
var React, _canvas, _context, _fraction, _radius;
var React;
React = __webpack_require__(/*! react */ 1);
React = __webpack_require__(1);
_radius = null;
_fraction = null;
_context = null;
_canvas = null;
module.exports = React.createClass({
_seconds: 0,
_radius: null,
_fraction: null,
_content: null,
_canvas: null,
propTypes: {

@@ -83,3 +77,2 @@ seconds: React.PropTypes.number,

return {
seconds: 60,
size: 300,

@@ -90,40 +83,31 @@ color: '#000',

},
getInitialState: function() {
return {
seconds: this.props.seconds
};
},
componentWillReceiveProps: function(props) {
return this.setState({
seconds: props.seconds
});
this._seconds = props.seconds;
return this._setupTimer();
},
componentWillMount: function() {
return this._setScale();
componentDidMount: function() {
this._seconds = this.props.seconds;
return this._setupTimer();
},
componentDidMount: function() {
if (!_canvas) {
this._setupCanvas();
}
_setupTimer: function() {
this._setScale();
this._setupCanvas();
this._drawTimer();
return this._startTimer();
},
componentDidUpdate: function() {
this._setScale();
_updateCanvas: function() {
this._clearTimer();
this._drawTimer();
if (this.state.seconds <= 0) {
return this._handleComplete();
}
return this._drawTimer();
},
_setScale: function() {
_radius = this.props.size / 2;
return _fraction = 2 / this.props.seconds;
this._radius = this.props.size / 2;
this._fraction = 2 / this._seconds;
return this._tickPeriod = this._seconds * 1.8;
},
_setupCanvas: function() {
_canvas = this.getDOMNode();
_context = _canvas.getContext('2d');
_context.textAlign = 'center';
_context.textBaseline = 'middle';
return _context.font = "bold " + (_radius / 2) + "px Arial";
this._canvas = this.getDOMNode();
this._context = this._canvas.getContext('2d');
this._context.textAlign = 'center';
this._context.textBaseline = 'middle';
return this._context.font = "bold " + (this._radius / 2) + "px Arial";
},

@@ -143,16 +127,16 @@ _startTimer: function() {

var duration;
duration = Date.now() - start;
_this.setState({
seconds: _this.state.seconds - duration / 1000
});
if (!(_this.state.seconds <= 0)) {
duration = (Date.now() - start) / 1000;
_this._seconds -= duration;
if (_this._seconds <= 0) {
_this._seconds = 0;
_this._handleComplete();
return _this._clearTimer();
} else {
_this._updateCanvas();
return _this._tick();
}
};
})(this)), 30);
})(this)), this._tickPeriod);
},
_handleComplete: function() {
this.setState({
seconds: 0
});
if (this.props.onComplete) {

@@ -163,25 +147,25 @@ return this.props.onComplete();

_clearTimer: function() {
_context.clearRect(0, 0, _canvas.width, _canvas.height);
this._context.clearRect(0, 0, this._canvas.width, this._canvas.height);
return this._drawBackground();
},
_drawBackground: function() {
_context.beginPath();
_context.globalAlpha = this.props.alpha / 3;
_context.arc(_radius, _radius, _radius, 0, Math.PI * 2, false);
_context.arc(_radius, _radius, _radius / 1.8, Math.PI * 2, 0, true);
return _context.fill();
this._context.beginPath();
this._context.globalAlpha = this.props.alpha / 3;
this._context.arc(this._radius, this._radius, this._radius, 0, Math.PI * 2, false);
this._context.arc(this._radius, this._radius, this._radius / 1.8, Math.PI * 2, 0, true);
return this._context.fill();
},
_drawTimer: function() {
var decimals, percent, _ref;
percent = _fraction * this.state.seconds + 1.5;
decimals = (_ref = this.state.seconds <= 9.9) != null ? _ref : {
var decimals, percent, ref;
percent = this._fraction * this._seconds + 1.5;
decimals = (ref = this._seconds <= 9.9) != null ? ref : {
1: 0
};
_context.globalAlpha = this.props.alpha;
_context.fillStyle = this.props.color;
_context.fillText(this.state.seconds.toFixed(decimals), _radius, _radius);
_context.beginPath();
_context.arc(_radius, _radius, _radius, Math.PI * 1.5, Math.PI * percent, false);
_context.arc(_radius, _radius, _radius / 1.8, Math.PI * percent, Math.PI * 1.5, true);
return _context.fill();
this._context.globalAlpha = this.props.alpha;
this._context.fillStyle = this.props.color;
this._context.fillText(this._seconds.toFixed(decimals), this._radius, this._radius);
this._context.beginPath();
this._context.arc(this._radius, this._radius, this._radius, Math.PI * 1.5, Math.PI * percent, false);
this._context.arc(this._radius, this._radius, this._radius / 1.8, Math.PI * percent, Math.PI * 1.5, true);
return this._context.fill();
},

@@ -200,5 +184,2 @@ render: function() {

/* 1 */
/*!**************************************************************************************!*\
!*** external {"root":"React","commonjs":"react","commonjs2":"react","amd":"react"} ***!
\**************************************************************************************/
/***/ function(module, exports, __webpack_require__) {

@@ -211,3 +192,3 @@

});
;
//# sourceMappingURL=react-countdown-clock.js.map
{
"name": "react-countdown-clock",
"version": "1.0.2",
"version": "1.0.3",
"description": "HTML5 canvas countdown clock React component",

@@ -28,3 +28,6 @@ "main": "build/react-countdown-clock.js",

"webpack": "^1.4.15"
},
"dependencies": {
"react": "^0.13.3"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc