公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
ui.util.throttle
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
包裝函式,允許每個間隔最多呼叫兩次。如果在延遲時間結束前多次呼叫包裝函式,系統只會處理第一次和最後一次呼叫。
使用範例:ui.Slider 的滑動事件回呼。回呼會立即執行,讓滑動動作感覺很靈敏。此外,系統保證會在使用者完成與滑桿的互動後執行回呼,確保最後一次回呼叫用可存取滑桿的最終值。
傳回包裝函式。
用量 | 傳回 |
---|
ui.util.throttle(func, delay, scope) | 函式 |
引數 | 類型 | 詳細資料 |
---|
func | 函式 | 要呼叫的函式。 |
delay | 數字 | 節流的延遲時間 (以毫秒為單位)。在延遲時間經過前,函式只能在初始呼叫後呼叫一次。 |
scope | 物件 (選用) | 要呼叫函式的範圍內的物件。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003eLimits a function's execution to at most twice per specified interval, ensuring responsiveness and capturing the final state.\u003c/p\u003e\n"],["\u003cp\u003eUseful for scenarios like UI slider events where immediate feedback and final value processing are crucial.\u003c/p\u003e\n"],["\u003cp\u003eWraps the original function and returns a new function that manages the throttling behavior.\u003c/p\u003e\n"],["\u003cp\u003eCustomizable with a delay parameter (in milliseconds) and an optional scope for execution context.\u003c/p\u003e\n"]]],[],null,["# ui.util.throttle\n\n\u003cbr /\u003e\n\nWraps a function to allow it to be called, at most, twice per interval. If the wrapper function is called multiple times before the delay elapses, only the first and the last calls will go through.\n\n\u003cbr /\u003e\n\nExample use: For the callback to a slide event on a ui.Slider. The callback will run immediately, making the slide action feel responsive. The callback is also guaranteed to run after the user has finished interacting with the slider, ensuring that the final callback invocation has access to the slider's final value.\n\nReturns the wrapped function.\n\n| Usage | Returns |\n|--------------------------------------------|----------|\n| `ui.util.throttle(func, delay, `*scope*`)` | Function |\n\n| Argument | Type | Details |\n|----------|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `func` | Function | The function to call. |\n| `delay` | Number | The delay, in milliseconds, for the throttle. The function can only be called once after the initial invocation until after the delay has elapsed. |\n| `scope` | Object, optional | The object in whose scope to call the function. |"]]