透過集合功能整理內容
你可以依據偏好儲存及分類內容。
blockly > utils > browserEvents > conditionalBind
utils.browserEvents.conditionalBind() 函式
繫結事件處理常式,如果該事件處理常式不在有效的觸控串流中,則可忽略。請在開始或繼續多重手勢的事件中使用此事件 (例如 mousedown 或 mousemove,可能會是拖曳或點擊的一部分)。
Signature:
export declare function conditionalBind(node: EventTarget, name: string, thisObject: object | null, func: Function, opt_noCaptureIdentifier?: boolean): Data;
參數
參數 |
類型 |
說明 |
節點 |
EventTarget |
要監聽的節點。 |
名稱 |
字串 |
要監聽的事件名稱 (例如「mousedown」)。 |
thisObject |
object | null |
函式中的「this」值。 |
func |
函式 |
觸發事件時要呼叫的函式。 |
opt_noCaptureIdentifier |
布林值 |
(選用) 如果觸發此事件不應阻斷對此觸控或其他同時觸控的其他事件處理常式執行作業,則為是。預設為 False。 |
退貨:
資料
可傳遞至 unbindEvent_ 的非公開資料。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[[["\u003cp\u003e\u003ccode\u003eutils.browserEvents.conditionalBind()\u003c/code\u003e allows binding event handlers that can be selectively ignored based on touch stream activity, making it suitable for multi-part gestures like dragging or clicking.\u003c/p\u003e\n"],["\u003cp\u003eThe function takes parameters for the target node, event name, function to execute, context (\u003ccode\u003ethis\u003c/code\u003e value), and an optional flag to control blocking behavior.\u003c/p\u003e\n"],["\u003cp\u003eIt returns an opaque data object that can be later used to unbind the event using \u003ccode\u003eunbindEvent_\u003c/code\u003e.\u003c/p\u003e\n"]]],["The `conditionalBind` function binds an event handler to a specified node. It takes the node, event name, a `this` object, the handler function, and an optional boolean to control blocking of other event handlers. When the event is triggered, the provided function is executed. This is intended for events related to multi-part gestures. It returns data used for unbinding the event later. This allows to control whether to block execution of other handlers for touches.\n"],null,["[blockly](./blockly.md) \\\u003e [utils](./blockly.utils_namespace.md) \\\u003e [browserEvents](./blockly.utils_namespace.browserevents_namespace.md) \\\u003e [conditionalBind](./blockly.utils_namespace.browserevents_namespace.conditionalbind_1_function.md)\n\nutils.browserEvents.conditionalBind() function\n----------------------------------------------\n\nBind an event handler that can be ignored if it is not part of the active touch stream. Use this for events that either start or continue a multi-part gesture (e.g. mousedown or mousemove, which may be part of a drag or click).\n\n**Signature:** \n\n export declare function conditionalBind(node: EventTarget, name: string, thisObject: object | null, func: Function, opt_noCaptureIdentifier?: boolean): Data;\n\nParameters\n----------\n\n| Parameter | Type | Description |\n|-------------------------|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| node | EventTarget | Node upon which to listen. |\n| name | string | Event name to listen to (e.g. 'mousedown'). |\n| thisObject | object \\| null | The value of 'this' in the function. |\n| func | Function | Function to call when event is triggered. |\n| opt_noCaptureIdentifier | boolean | *(Optional)* True if triggering on this event should not block execution of other event handlers on this touch or other simultaneous touches. False by default. |\n\n**Returns:**\n\n[Data](./blockly.browserevents_namespace.data_typealias.md)\n\nOpaque data that can be passed to unbindEvent_."]]