Meilleure gestion du délai sur un lancement d'application
This commit is contained in:
parent
3ded369d09
commit
69cc5a6d39
|
@ -1,8 +1,17 @@
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
|
var logger = require('../../util/logger');
|
||||||
var AppIcon = require('../common/app-icon.js');
|
var AppIcon = require('../common/app-icon.js');
|
||||||
|
|
||||||
|
var MIN_CLICK_DELTATIME = 2000;
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
|
|
||||||
|
getInitialState: function() {
|
||||||
|
return {
|
||||||
|
lastClickTimestamp: 0
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
item: React.PropTypes.object.isRequired,
|
item: React.PropTypes.object.isRequired,
|
||||||
itemPath: React.PropTypes.oneOfType([
|
itemPath: React.PropTypes.oneOfType([
|
||||||
|
@ -13,7 +22,15 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_onItemClick: function(evt) {
|
_onItemClick: function(evt) {
|
||||||
|
|
||||||
|
var clickDeltaTime = Date.now() - this.state.lastClickTimestamp;
|
||||||
|
if( clickDeltaTime < MIN_CLICK_DELTATIME ) {
|
||||||
|
logger.debug('Item "%s" clicked within %sms. No action.', this.props.itemPath, MIN_CLICK_DELTATIME);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
this.setState({ lastClickTimestamp: Date.now() });
|
||||||
this.props.onItemClick(evt, this.props.itemPath, this.props.item);
|
this.props.onItemClick(evt, this.props.itemPath, this.props.item);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,9 @@ var connect = require('react-redux').connect;
|
||||||
var logger = require('../../util/logger');
|
var logger = require('../../util/logger');
|
||||||
var CrossfadeImage = require('../common/crossfade-image');
|
var CrossfadeImage = require('../common/crossfade-image');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var _ = require('lodash');
|
|
||||||
|
|
||||||
var DEFAULT_PROFILE = path.join(__dirname, '..', '..', '..', 'default-profile.json');
|
var DEFAULT_PROFILE = path.join(__dirname, '..', '..', '..', 'default-profile.json');
|
||||||
var DEFAULT_BACKGROUND = '';
|
var DEFAULT_BACKGROUND = '';
|
||||||
var MIN_CLICK_DELTATIME = 2000;
|
|
||||||
|
|
||||||
var LauncherView = React.createClass({
|
var LauncherView = React.createClass({
|
||||||
|
|
||||||
|
@ -93,12 +91,6 @@ var LauncherView = React.createClass({
|
||||||
|
|
||||||
logger.debug(item);
|
logger.debug(item);
|
||||||
|
|
||||||
var clickDeltaTime = Date.now() - this.state.lastClickTimestamp;
|
|
||||||
if( clickDeltaTime < MIN_CLICK_DELTATIME ) {
|
|
||||||
logger.debug('Item clicked within %sms. No action.', MIN_CLICK_DELTATIME);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(item.items) {
|
if(item.items) {
|
||||||
|
|
||||||
this.play(this.refs.appList, 'slide-out-left 250ms ease-in-out')
|
this.play(this.refs.appList, 'slide-out-left 250ms ease-in-out')
|
||||||
|
@ -126,8 +118,6 @@ var LauncherView = React.createClass({
|
||||||
logger.info('No action associated with item "'+item.label+'".');
|
logger.info('No action associated with item "'+item.label+'".');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({ lastClickTimestamp: Date.now() });
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_getItemByPath: function(itemPath, rootItem) {
|
_getItemByPath: function(itemPath, rootItem) {
|
||||||
|
|
Loading…
Reference in New Issue