モバイルサイトで使用deviceorientation
していますが、すべての動きをキャプチャしたくありません。1 秒あたり 1 つだけが必要なので、throttle-debounce プラグインを使用しようとしています。
私の元の作業コードは次のようになりました...
window.addEventListener(
'deviceorientation',
function (event) {
tilt([event.alpha, event.beta, event.gamma]);
},
true);
...しかし、スロットルをこのように追加すると...
window.addEventListener(
'deviceorientation',
$.throttle(
1000,
function (event){
tilt([event.alpha, event.beta, event.gamma]);
}),
true);
...私は...
Uncaught TypeError: Object function ( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context, rootjQuery );
} has no method 'throttle'
構文が間違っていると思いますが、いくつかのバリエーションを試しましたが、うまくいきません。ヘルプ?
プラグインなしで同じことを行うより良い方法があれば、それは同じくらい良いでしょう:)