Polymer utility functions, mixins, modules and styles.
bower i StartPolymer/s-utils -S
<link rel="import" href="../bower_components/s-utils/utils-es5/throttle.html">
<link rel="import" href="../bower_components/s-utils/utils/throttle.html">
Creates a throttled function that only invokes callback
at most once per every wait
milliseconds.
See David Corbacho's article for details over the differences between throttle and debounce techniques.
// Limiting the api call thrice a second.
var resultFunction = S.Utils.throttle(_apiCall, 1000, 3);
// Calling the closure function in every 100 milliseconds.
setInterval(function () {
resultFunction();
}, 100);
Inspired by https://stackoverflow.com/a/42975776/1614237
Creates a throttled function that only invokes callback
at most once per frame using requestAnimationFrame
.
Ideal using for mouse, resize, scroll events.
window.addEventListener('resize', S.Utils.throttlePerFrame(this._onOptimizedResize));
Inspired by raf-throttle
Returns a timestamp measured in milliseconds, accurate to five thousandths of a millisecond (5 microseconds).
S.Utils.timestamp()
Module that provides a number of properties for detection of browser types and features.
S.Utils.Browser.hasTouchScreen
S.Utils.Browser.isIE
S.Utils.Browser.onAndroid