JSFiddle - React, Tailwind, and code Playground
by Ryan Duffy
HTML
<div id="log"></div>
JavaScript
enyo._debounced = {};
enyo.debounce = function (name, method, threshold) {
if(!enyo._debounced[name]) {
this.log("firing");
method.apply(window, arguments);
enyo._debounced[name] = setTimeout(function() {
delete enyo._debounced[name];
}, threshold);
}
}
enyo.kind({
name:"ex.App",
kind: "Scroller",
handlers:{
onmousemove: "moved"
},
components:[
{name:"log", allowHtml:true}
],
moved: function() {
enyo.debounce("moved", enyo.bind(this, "_moved"), 500);
},
_moved: function() {
this.$.log.addContent("moved @ " + new Date().toLocaleString() + "<br>");
}
});
new ex.App().renderInto(document.body);