Ajout debounce chargement icone

This commit is contained in:
wpetit 2015-10-19 13:24:05 +02:00
parent 150011dbe7
commit c1fe1884e2

View File

@ -2,6 +2,7 @@ var React = require('react');
var Util = require('../../util');
var LazyLoad = require('../mixins/lazy-load');
var debug = Util.Debug('common:app-icon');
var _ = require('lodash');
var LOADING_ICON = 'img/hourglass.svg';
var DEFAULT_ICON = 'img/default-icon.svg';
@ -10,6 +11,12 @@ module.exports = React.createClass({
mixins: [LazyLoad],
componentWillMount: function() {
if(!this._findIconDebounced) {
this._findIconDebounced = _.debounce(this._findIcon, 250);
}
},
getInitialState: function() {
return { icon: DEFAULT_ICON, iconPath: DEFAULT_ICON, currentTheme: '' };
},
@ -33,7 +40,7 @@ module.exports = React.createClass({
this.setState({ icon: newIcon, iconPath: LOADING_ICON, currentTheme: newTheme });
this._findIcon(newIcon, newTheme);
this._findIconDebounced(newIcon, newTheme);
},