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 Mar 3, 2014
1 parent c9cb9b3 commit 0d0301e
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;

Expand Down Expand Up @@ -169,7 +170,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 @@ -247,8 +251,8 @@ var LiveCSSEditor = function (settings) {
addEditorPane();

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

0 comments on commit 0d0301e

Please sign in to comment.