Skip to content

Instantly share code, notes, and snippets.

@JDMcKinstry
Created March 19, 2012 19:05
Show Gist options
  • Save JDMcKinstry/2124294 to your computer and use it in GitHub Desktop.
Save JDMcKinstry/2124294 to your computer and use it in GitHub Desktop.
// Again, what you name the function is clearly up to you, I wouldn't really recommend my example name as it is just plain bad :P
function stopType() {
// The following if statement will check if your timer has been assigned yet, and if so, clears it so it will no longer continue to your work function
if (tmrStopType!= undefined) clearTimeout(tmrStopType);
// The following will attempt to start your work function after 2 seconds unless interrupted and reset by previous if statement
// Also, many people would rather write this statement as tmrStopType= setTimeout(stopTypeWork(), 2000);
// If, you want to, that is fine, i don't because it is not a style of timer writing that is readable to ALL browsers, however, the following is
tmrStopType= setTimeout(function (){ stopTypeWork() }, 2000);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment