🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

react-idle-timer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-idle-timer - npm Package Compare versions

Comparing version

to
1.2.10

@@ -5,2 +5,6 @@ 'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
var _react = require('react');

@@ -40,3 +44,4 @@

_this.state = { idle: false,
_this.state = {
idle: false,
oldDate: +new Date(),

@@ -51,2 +56,3 @@ lastActive: +new Date(),

(0, _lodash2.default)(_this, ['_toggleIdleState', '_handleEvent', 'reset', 'pause', 'resume', 'getRemainingTime', 'getElapsedTime', 'getLastActiveTime', 'isIdle']);
return _this;

@@ -69,2 +75,5 @@ }

// Clear timeout to prevent delayed state changes
clearTimeout(this.state.tId);
// Unbind all events
this.props.events.forEach(function (e) {

@@ -77,7 +86,3 @@ return _this3.props.element.removeEventListener(e, _this3._handleEvent);

value: function render() {
return _react2.default.createElement(
'div',
null,
this.props.children ? this.props.children : ''
);
return this.props.children ? this.props.children : '';
}

@@ -100,3 +105,5 @@

// Set the state
this.setState({ idle: !this.state.idle });
this.setState({
idle: !this.state.idle
});

@@ -139,4 +146,7 @@ // Fire the appropriate action

this.setState({ lastActive: +new Date() // store when user was last active
this.setState({
lastActive: +new Date() // store when user was last active
, pageX: e.pageX // update mouse coord
, pageY: e.pageY,

@@ -165,3 +175,4 @@ tId: setTimeout(this._toggleIdleState, this.props.timeout) // set a new timeout

// reset settings
this.setState({ idle: false,
this.setState({
idle: false,
oldDate: +new Date(),

@@ -192,3 +203,5 @@ lastActive: this.state.oldDate,

// define how much is left on the timer
this.setState({ remaining: this.props.timeout - (+new Date() - this.state.oldDate) });
this.setState({
remaining: this.props.timeout - (+new Date() - this.state.oldDate)
});
}

@@ -211,3 +224,4 @@

if (!this.state.idle) {
this.setState({ tId: setTimeout(this._toggleIdleState, this.state.remaining),
this.setState({
tId: setTimeout(this._toggleIdleState, this.state.remaining),
remaining: null

@@ -286,12 +300,13 @@ });

IdleTimer.propTypes = { timeout: _react.PropTypes.number // Activity timeout
, events: _react.PropTypes.arrayOf(_react.PropTypes.string) // Activity events to bind
, idleAction: _react.PropTypes.func // Action to call when user becomes inactive
, activeAction: _react.PropTypes.func // Action to call when user becomes active
, element: _react.PropTypes.oneOfType([_react.PropTypes.object, _react.PropTypes.string]) // Element ref to watch activty on
, format: _react.PropTypes.string
IdleTimer.propTypes = {
timeout: _react.PropTypes.number, // Activity timeout
events: _react.PropTypes.arrayOf(_react.PropTypes.string), // Activity events to bind
idleAction: _react.PropTypes.func, // Action to call when user becomes inactive
activeAction: _react.PropTypes.func, // Action to call when user becomes active
element: _react.PropTypes.oneOfType([_react.PropTypes.object, _react.PropTypes.string]), // Element ref to watch activty on
format: _react.PropTypes.string
};
IdleTimer.defaultProps = { timeout: 1000 * 60 * 20 // 20 minutes
, events: ['mousemove', 'keydown', 'wheel', 'DOMMouseScroll', 'mouseWheel', 'mousedown', 'touchstart', 'touchmove', 'MSPointerDown', 'MSPointerMove'],
IdleTimer.defaultProps = {
timeout: 1000 * 60 * 20, // 20 minutes
events: ['mousemove', 'keydown', 'wheel', 'DOMMouseScroll', 'mouseWheel', 'mousedown', 'touchstart', 'touchmove', 'MSPointerDown', 'MSPointerMove'],
idleAction: function idleAction() {},

@@ -301,4 +316,2 @@ activeAction: function activeAction() {},

};
module.exports = IdleTimer;
module.exports['default'] = IdleTimer;
exports.default = IdleTimer;

@@ -5,2 +5,6 @@ 'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
var _redboxReact2 = require('redbox-react');

@@ -72,3 +76,4 @@

_this.state = { timeout: 3000,
_this.state = {
timeout: 3000,
remaining: null,

@@ -117,51 +122,55 @@ isIdle: false,

_react3.default.createElement(
'h1',
'div',
null,
'Timeout: ',
this.state.timeout,
'ms'
_react3.default.createElement(
'h1',
null,
'Timeout: ',
this.state.timeout,
'ms'
),
_react3.default.createElement(
'h1',
null,
'Time Remaining: ',
this.state.remaining
),
_react3.default.createElement(
'h1',
null,
'Time Elapsed: ',
this.state.elapsed
),
_react3.default.createElement(
'h1',
null,
'Last Active: ',
this.state.lastActive
),
_react3.default.createElement(
'h1',
null,
'Idle: ',
this.state.isIdle.toString()
)
),
_react3.default.createElement(
'h1',
'div',
null,
'Time Remaining: ',
this.state.remaining
),
_react3.default.createElement(
'h1',
null,
'Time Elapsed: ',
this.state.elapsed
),
_react3.default.createElement(
'h1',
null,
'Last Active: ',
this.state.lastActive
),
_react3.default.createElement(
'h1',
null,
'Idle: ',
this.state.isIdle.toString()
_react3.default.createElement(
'button',
{ onClick: this._reset },
'RESET'
),
_react3.default.createElement(
'button',
{ onClick: this._pause },
'PAUSE'
),
_react3.default.createElement(
'button',
{ onClick: this._resume },
'RESUME'
)
)
),
_react3.default.createElement(
'div',
null,
_react3.default.createElement(
'button',
{ onClick: this._reset },
'RESET'
),
_react3.default.createElement(
'button',
{ onClick: this._pause },
'PAUSE'
),
_react3.default.createElement(
'button',
{ onClick: this._resume },
'RESUME'
)
)

@@ -207,3 +216,2 @@ );

module.exports = App;
module.exports['default'] = App;
exports.default = App;

@@ -30,12 +30,15 @@ 'use strict';

app.use((0, _webpackDevMiddleware2.default)(compiler, { noInfo: true,
publicPath: _webpackDev2.default.output.publicPath
app.use((0, _webpackDevMiddleware2.default)(compiler, {
noInfo: true,
publicPath: _webpackDev2.default.output.publicPath
}));
app.use((0, _webpackHotMiddleware2.default)(compiler));
app.get('*', function (req, res) {
return res.sendFile((0, _path.join)(__dirname, 'index.html'));
return res.sendFile((0, _path.join)(__dirname, 'index.html'));
});
app.listen(3000, 'localhost', function (err) {
if (err) console.log(err);else console.log('Listening at http://localhost:3000');
if (err) return console.log(err);
console.log('Listening at http://localhost:3000');
});
{
"name": "react-idle-timer",
"version": "1.2.9",
"version": "1.2.10",
"description": "Activity detection for React.js",

@@ -51,2 +51,3 @@ "main": "build/index.js",

"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.5.0",
"del": "^1.2.0",

@@ -53,0 +54,0 @@ "eslint": "^1.10.3",