Skip to content

UIScreenEdgePanGestureRecognizer ​

UIScreenEdgePanGestureRecognizer represents a screen-edge pan gesture recognizer: it only recognizes drags that start at the edge of the screen and move inward. Otherwise it is the same as UIPanGestureRecognizer, and its event object also carries translation and velocity.

edges defaults to an empty array; until it is set, no gesture is recognized. Add the recognizer to a view that contains the screen edge, usually a view controller's full-screen view.

Three defaults differ from the parent class:

PropertyUIPanGestureRecognizerUIScreenEdgePanGestureRecognizer
maximumNumberOfTouches42949672951
delaysTouchesBeganfalsetrue
edgesNo such property[]

Screen-edge dragging has not been checked with real touches, and the gesture itself is not verified in the simulator.

Inheritance: EventTarget → NSObject → UIGestureRecognizer → UIPanGestureRecognizer → UIScreenEdgePanGestureRecognizer

For how to use it, see the guide Responding to gestures.

Constructor ​

UIScreenEdgePanGestureRecognizer()

Creates a screen-edge pan gesture recognizer. Set edges before it can recognize a gesture.

Instance properties ​

Also inherits the properties and methods of UIPanGestureRecognizer and UIGestureRecognizer, including translationInView(), velocityInView(), and setTranslation().

PropertyDescription
edgesWhich screen edges a recognized drag can start from

Events ​

The events come from UIGestureRecognizer; listen with addEventListener(). It fires:

EventWhen it fires
beganWhen a drag from the edge is recognized
changedEach time the finger moves after that
endedWhen the finger lifts
cancelledWhen interrupted

Examples ​

js
const page = new UIView();
const fromRight = new UIScreenEdgePanGestureRecognizer();
fromRight.edges = ['right'];
fromRight.addEventListener('began', () => {
  console.log('Dragged in from the right edge');
});
page.addGestureRecognizer(fromRight);

Effect: when page fills the screen, dragging a finger left from the right edge of the screen logs Dragged in from the right edge. A drag that starts in the middle of the screen logs nothing. Not verified in the simulator.

Corresponding iOS API ​

ObjCJS
edgePan.edges = UIRectEdgeRightedgePan.edges = ['right']
edgePan.edges = UIRectEdgeAlledgePan.edges = ['top', 'left', 'bottom', 'right']

See also ​