Stay organized with collections
Save and categorize content based on your preferences.
blockly > utils > browserEvents > conditionalBind
utils.browserEvents.conditionalBind() function
Bind 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).
Signature:
export declare function conditionalBind(node: EventTarget, name: string, thisObject: object | null, func: Function, opt_noCaptureIdentifier?: boolean): Data;
Parameters
Parameter |
Type |
Description |
node |
EventTarget |
Node upon which to listen. |
name |
string |
Event name to listen to (e.g. 'mousedown'). |
thisObject |
object | null |
The value of 'this' in the function. |
func |
Function |
Function to call when event is triggered. |
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. |
Returns:
Data
Opaque data that can be passed to unbindEvent_.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-16 UTC."],[[["`utils.browserEvents.conditionalBind()` 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."],["The function takes parameters for the target node, event name, function to execute, context (`this` value), and an optional flag to control blocking behavior."],["It returns an opaque data object that can be later used to unbind the event using `unbindEvent_`."]]],["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"]]