https://github.com/startpolymer/s-utils
Polymer utility functions, mixins, modules and styles.
https://github.com/startpolymer/s-utils
polymer throttle utilities utils
Last synced: 7 months ago
JSON representation
Polymer utility functions, mixins, modules and styles.
- Host: GitHub
- URL: https://github.com/startpolymer/s-utils
- Owner: StartPolymer
- Created: 2017-07-24T21:18:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-25T12:15:12.000Z (over 8 years ago)
- Last Synced: 2025-03-25T14:32:42.586Z (10 months ago)
- Topics: polymer, throttle, utilities, utils
- Language: HTML
- Homepage:
- Size: 29.3 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# StartPolymer Utilities
[](https://help.github.com/articles/about-pull-requests/)
Polymer utility functions, mixins, modules and styles.
## Install
`bower i StartPolymer/s-utils -S`
## Import
### Polymer 1.0
```html
```
### Polymer 2.0
```html
```
## Functions
### throttle() from throttle.html
Creates a throttled function that only invokes `callback` at most once per every `wait` milliseconds.
> See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
for details over the differences between throttle and debounce techniques.
```js
// 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
### throttlePerFrame() from throttle.html
Creates a throttled function that only invokes `callback` at most once per frame using `requestAnimationFrame`.
Ideal using for mouse, resize, scroll events.
```js
window.addEventListener('resize', S.Utils.throttlePerFrame(this._onOptimizedResize));
```
> Inspired by [raf-throttle](https://github.com/wuct/raf-throttle)
### timestamp() from date.html
Returns a timestamp measured in milliseconds, accurate to five thousandths of a millisecond (5 microseconds).
```js
S.Utils.timestamp()
```
## Modules
### Browser from browser.html
Module that provides a number of properties for detection of browser types and features.
```js
S.Utils.Browser.hasTouchScreen
S.Utils.Browser.isIE
S.Utils.Browser.onAndroid
```