Skip to content

Commit

Permalink
Use a timeout as a debouncer
Browse files Browse the repository at this point in the history
Per #1
  • Loading branch information
jhubert committed Dec 2, 2014
1 parent 1faf163 commit 234f022
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions chrome/source/css_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var LiveCSSEditor = function (settings) {
settings = settings || { warn: true, save: true, modify: true };

var cssCache = '',
keyupTimer = null,
tab = ' ',
urlKey = document.location,
cssPrefix = 'LiveCSSEditor-';
Expand Down Expand Up @@ -195,7 +196,10 @@ var LiveCSSEditor = function (settings) {
bottomButton.onclick = toggleBottom;
closeButton.onclick = removeEditor;
codeArea.onkeydown = handleTabInTextarea;
codeArea.onkeyup = updateCSSTag;
codeArea.onkeyup = function () {
keyupTimer && clearTimeout(keyupTimer);
keyupTimer = setTimeout(updateCSSTag, 100);
};
leftRightButton.onclick = toggleLeftRight;
resetButton.onclick = resetBoxSize;
}
Expand Down Expand Up @@ -289,8 +293,8 @@ var LiveCSSEditor = function (settings) {
addEditorPane();

css = getStorage('cache');
if (css) {
source = getEl('code');
source = getEl('code');
if (css && source) {
source.value = css;
}
fillStyleTag(css);
Expand Down

0 comments on commit 234f022

Please sign in to comment.