Skip to content

Commit

Permalink
Merge pull request #2798 from thfrei/excalidraw
Browse files Browse the repository at this point in the history
New note type `canvas-note` using excalidraw (hand drawn notes, sketching, pen)
  • Loading branch information
zadam authored May 12, 2022
2 parents 6906c82 + 8df3b0a commit 87b75a9
Show file tree
Hide file tree
Showing 26 changed files with 2,695 additions and 1,052 deletions.
70 changes: 70 additions & 0 deletions libraries/lodash.debounce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Returns a function, that, as long as it continues to be invoked, will not
* be triggered. The function will be called after it stops being called for
* N milliseconds. If `immediate` is passed, trigger the function on the
* leading edge, instead of the trailing. The function also has a property 'clear'
* that is a function which will clear the timer to prevent previously scheduled executions.
*
* @source underscore.js
* @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
* @param {Function} function to wrap
* @param {Number} timeout in ms (`100`)
* @param {Boolean} whether to execute at the beginning (`false`)
* @api public
*/
function debounce(func, wait_ms, immediate){
var timeout, args, context, timestamp, result;
if (null == wait_ms) wait_ms = 100;

function later() {
var last = Date.now() - timestamp;

if (last < wait_ms && last >= 0) {
timeout = setTimeout(later, wait_ms - last);
} else {
timeout = null;
if (!immediate) {
result = func.apply(context, args);
context = args = null;
}
}
};

var debounced = function(){
context = this;
args = arguments;
timestamp = Date.now();
var callNow = immediate && !timeout;
if (!timeout) timeout = setTimeout(later, wait_ms);
if (callNow) {
result = func.apply(context, args);
context = args = null;
}

return result;
};

debounced.clear = function() {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
};

debounced.flush = function() {
if (timeout) {
result = func.apply(context, args);
context = args = null;

clearTimeout(timeout);
timeout = null;
}
};

return debounced;
};

// Adds compatibility for ES modules
debounce.debounce = debounce;

export default debounce;
Loading

0 comments on commit 87b75a9

Please sign in to comment.