/** * Copyright (c) Nicolas Gallagher * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ /** * RESPONDER EVENT SYSTEM * * A single, global "interaction lock" on views. For a view to be the "responder" means * that pointer interactions are exclusive to that view and none other. The "interaction * lock" can be transferred (only) to ancestors of the current "responder" as long as * pointers continue to be active. * * Responder being granted: * * A view can become the "responder" after the following events: * * "pointerdown" (implemented using "touchstart", "mousedown") * * "pointermove" (implemented using "touchmove", "mousemove") * * "scroll" (while a pointer is down) * * "selectionchange" (while a pointer is down) * * If nothing is already the "responder", the event propagates to (capture) and from * (bubble) the event target until a view returns `true` for * `on*ShouldSetResponder(Capture)`. * * If something is already the responder, the event propagates to (capture) and from * (bubble) the lowest common ancestor of the event target and the current "responder". * Then negotiation happens between the current "responder" and a view that wants to * become the "responder": see the timing diagram below. * * (NOTE: Scrolled views either automatically become the "responder" or release the * "interaction lock". A native scroll view that isn't built on top of the responder * system must result in the current "responder" being notified that it no longer has * the "interaction lock" - the native system has taken over. * * Responder being released: * * As soon as there are no more active pointers that *started* inside descendants * of the *current* "responder", an `onResponderRelease` event is dispatched to the * current "responder", and the responder lock is released. * * Typical sequence of events: * * startShouldSetResponder * * responderGrant/Reject * * responderStart * * responderMove * * responderEnd * * responderRelease */ import { ResponderEvent } from './createResponderEvent'; declare type ResponderId = number; export declare type ResponderConfig = { onResponderEnd?: (e: ResponderEvent) => void; onResponderGrant?: (e: ResponderEvent) => void; onResponderMove?: (e: ResponderEvent) => void; onResponderRelease?: (e: ResponderEvent) => void; onResponderReject?: (e: ResponderEvent) => void; onResponderStart?: (e: ResponderEvent) => void; onResponderTerminate?: (e: ResponderEvent) => void; onResponderTerminationRequest?: (e: ResponderEvent) => boolean; onStartShouldSetResponder?: (e: ResponderEvent) => boolean; onStartShouldSetResponderCapture?: (e: ResponderEvent) => boolean; onMoveShouldSetResponder?: (e: ResponderEvent) => boolean; onMoveShouldSetResponderCapture?: (e: ResponderEvent) => boolean; onScrollShouldSetResponder?: (e: ResponderEvent) => boolean; onScrollShouldSetResponderCapture?: (e: ResponderEvent) => boolean; onSelectionChangeShouldSetResponder?: (e: ResponderEvent) => boolean; onSelectionChangeShouldSetResponderCapture?: (e: ResponderEvent) => boolean; }; /** * Process native events * * A single event listener is used to manage the responder system. * Native events * are interpreted in terms of the Responder System and checked to see if * the responder should be transferred. Each host node that is attached to * the Responder System has an ID, which is used to look up its associated * callbacks. */ export declare function eventListener(domEvent: any): void; export declare const domEvents: { onTouchStart: typeof eventListener; onTouchMove: typeof eventListener; onTouchEnd: typeof eventListener; onTouchCancel: typeof eventListener; onContextMenu: (e: any) => void; }; export declare function attachListeners(dom?: Document): () => void; export declare function attachDocumentListeners(): void; /** * Register a node with the ResponderSystem. */ export declare function addNode(id: ResponderId, node: any, config: ResponderConfig): void; /** * Unregister a node with the ResponderSystem. */ export declare function removeNode(id: ResponderId): void; /** * Allow the current responder to be terminated from within components to support * more complex requirements, such as use with other React libraries for working * with scroll views, input views, etc. */ export declare function terminateResponder(): void; export {};