MCPcopy Create free account
hub / github.com/ionic-team/ionic-framework / canStart

Function canStart

core/src/components/modal/gestures/sheet.ts:262–299  ·  view source on GitHub ↗
(detail: GestureDetail)

Source from the content-addressed store, hash-verified

260 }
261
262 const canStart = (detail: GestureDetail) => {
263 /**
264 * If we are swiping on the content, swiping should only be possible if the content
265 * is scrolled all the way to the top so that we do not interfere with scrolling.
266 *
267 * We cannot assume that the `ion-content` target will remain consistent between swipes.
268 * For example, when using ion-nav within a modal it is possible to swipe, push a view,
269 * and then swipe again. The target content will not be the same between swipes.
270 */
271 const contentEl = findClosestIonContent(detail.event.target! as HTMLElement);
272 currentBreakpoint = getCurrentBreakpoint();
273
274 /**
275 * If `expandToScroll` is disabled, we should not allow the swipe gesture
276 * to start if the content is not scrolled to the top.
277 */
278 if (!expandToScroll && contentEl) {
279 const scrollEl = isIonContent(contentEl) ? getElementRoot(contentEl).querySelector('.inner-scroll') : contentEl;
280 return scrollEl!.scrollTop === 0;
281 }
282
283 if (currentBreakpoint === 1 && contentEl) {
284 /**
285 * The modal should never swipe to close on the content with a refresher.
286 * Note 1: We cannot solve this by making this gesture have a higher priority than
287 * the refresher gesture as the iOS native refresh gesture uses a scroll listener in
288 * addition to a gesture.
289 *
290 * Note 2: Do not use getScrollElement here because we need this to be a synchronous
291 * operation, and getScrollElement is asynchronous.
292 */
293 const scrollEl = isIonContent(contentEl) ? getElementRoot(contentEl).querySelector('.inner-scroll') : contentEl;
294 const hasRefresherInContent = !!contentEl.querySelector('ion-refresher');
295 return !hasRefresherInContent && scrollEl!.scrollTop === 0;
296 }
297
298 return true;
299 };
300
301 const onStart = (detail: GestureDetail) => {
302 /**

Callers

nothing calls this directly

Calls 3

findClosestIonContentFunction · 0.90
isIonContentFunction · 0.90
getElementRootFunction · 0.90

Tested by

no test coverage detected