cancelScheduledGesture() — react Function Reference
Architecture documentation for the cancelScheduledGesture() function in ReactFiberGestureScheduler.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 2e4f42a5_889a_dc6d_59d1_91763f97c720["cancelScheduledGesture()"] 8193bb5a_9f72_452e_5391_5f40038fa638["ReactFiberGestureScheduler.js"] 2e4f42a5_889a_dc6d_59d1_91763f97c720 -->|defined in| 8193bb5a_9f72_452e_5391_5f40038fa638 586b8bc3_6725_2de7_9f53_bd5c2c11627e["G()"] 586b8bc3_6725_2de7_9f53_bd5c2c11627e -->|calls| 2e4f42a5_889a_dc6d_59d1_91763f97c720 1b2584b3_97ce_42e6_080f_e2dfd9f999a6["requestTransitionLane()"] 2e4f42a5_889a_dc6d_59d1_91763f97c720 -->|calls| 1b2584b3_97ce_42e6_080f_e2dfd9f999a6 style 2e4f42a5_889a_dc6d_59d1_91763f97c720 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-reconciler/src/ReactFiberGestureScheduler.js lines 132–222
export function cancelScheduledGesture(
root: FiberRoot,
gesture: ScheduledGesture,
): void {
// Entangle any Transitions started in this event with the revertLane of the gesture
// so that we commit them all together.
if (gesture.revertLane !== NoLane) {
const entangledLanes = gesture.revertLane | requestTransitionLane(null);
markRootEntangled(root, entangledLanes);
}
gesture.count--;
if (gesture.count === 0) {
// If the end state is closer to the end than the beginning then we commit into the
// end state before reverting back (or applying a new Transition).
// Otherwise we just revert back and don't commit.
let shouldCommit: boolean;
const finalOffset = getCurrentGestureOffset(gesture.provider);
const rangeStart = gesture.rangeStart;
const rangeEnd = gesture.rangeEnd;
if (rangeStart < rangeEnd) {
shouldCommit = finalOffset > rangeStart + (rangeEnd - rangeStart) / 2;
} else {
shouldCommit = finalOffset < rangeEnd + (rangeStart - rangeEnd) / 2;
}
// TODO: If we're currently rendering this gesture, we need to restart the render
// on a different gesture or cancel the render..
// TODO: We might want to pause the View Transition at this point since you should
// no longer be able to update the position of anything but it might be better to
// just commit the gesture state.
const runningTransition = gesture.running;
if (runningTransition !== null && shouldCommit) {
// If we are going to commit this gesture in its to state, we need to wait to
// stop it until it commits. We should now schedule a render at the gesture
// lane to actually commit it.
gesture.committing = true;
if (root.pendingGestures === gesture) {
const commitCallback = gesture.commit;
if (commitCallback !== null) {
gesture.commit = null;
// If we already have a commit prepared we can immediately commit the tree
// without rerendering.
// TODO: Consider scheduling this in a task instead of synchronously inside the last cancellation.s
commitCallback();
} else {
// Ping the root given the new state. This is similar to pingSuspendedRoot.
pingGestureRoot(root);
}
}
} else {
// If we're not going to commit this gesture we can stop the View Transition
// right away and delete the scheduled gesture from the pending queue.
if (gesture.prev === null) {
if (root.pendingGestures === gesture) {
// This was the currently rendering gesture.
root.pendingGestures = gesture.next;
let remainingLanes = root.pendingLanes;
if (root.pendingGestures === null) {
// Gestures don't clear their lanes while the gesture is still active but it
// might not be scheduled to do any more renders and so we shouldn't schedule
// any more gesture lane work until a new gesture is scheduled.
remainingLanes &= ~GestureLane;
}
markRootFinished(
root,
GestureLane,
remainingLanes,
NoLane,
NoLane,
NoLanes,
);
// If we had a currently rendering gesture we need to now reset the gesture lane to
// now render the next gesture or cancel if there's no more gestures in the queue.
restartGestureRoot(root);
}
gesture.running = null;
if (runningTransition !== null) {
stopViewTransition(runningTransition);
}
} else {
// This was not the current gesture so it doesn't affect the current render.
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does cancelScheduledGesture() do?
cancelScheduledGesture() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberGestureScheduler.js.
Where is cancelScheduledGesture() defined?
cancelScheduledGesture() is defined in packages/react-reconciler/src/ReactFiberGestureScheduler.js at line 132.
What does cancelScheduledGesture() call?
cancelScheduledGesture() calls 1 function(s): requestTransitionLane.
What calls cancelScheduledGesture()?
cancelScheduledGesture() is called by 1 function(s): G.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free