1.3.4 • Published 6 years ago

@sygnas/throttle v1.3.4

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

syg-throttle

Adjust the timing of event execution.

イベントの実行タイミングを調整。

Description

windowの scrollイベントや、 resizeイベントの実行タイミングをミリ秒間隔で指定して遅延させるもの。

Usage

Install

npm install --save @sygnas/throttle

Script

import throttle from '@sygnas/throttle';

function foo() {
    console.log("scroll");
}

window.addEventListener('scroll', throttle(200, foo, this));

Params

throttle(timing, function, scope)
引数説明
timingintミリ秒。ここで指定した時間が経過しないと function を実行しない
functionfunctionイベントで実行したい関数
scopeobject関数を実行するスコープを指定

License

MIT