@ionic/core 7.3.4-dev.11694542086.1f624b36 → 7.3.4-dev.11694548895.1578981b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/input-shims.js +18 -78
- package/dist/cjs/{input-shims-d8e322aa.js → input-shims-93284c80.js} +18 -79
- package/dist/cjs/ion-app_8.cjs.entry.js +1 -1
- package/dist/collection/utils/input-shims/hacks/scroll-assist.js +16 -75
- package/dist/collection/utils/input-shims/hacks/scroll-data.js +2 -3
- package/dist/docs.json +1 -1
- package/dist/esm/{input-shims-c738363e.js → input-shims-4f1b0af9.js} +18 -79
- package/dist/esm/ion-app_8.entry.js +1 -1
- package/dist/esm-es5/input-shims-4f1b0af9.js +4 -0
- package/dist/esm-es5/ion-app_8.entry.js +1 -1
- package/dist/ionic/ionic.esm.js +1 -1
- package/dist/ionic/p-1d4a4a94.system.js +4 -0
- package/dist/ionic/p-c4abd708.js +4 -0
- package/dist/ionic/p-c68a8814.system.js +1 -1
- package/dist/ionic/{p-c2b524f3.system.entry.js → p-d524e68b.system.entry.js} +1 -1
- package/dist/ionic/{p-7b14f1a9.entry.js → p-fc991193.entry.js} +1 -1
- package/dist/types/utils/input-shims/hacks/scroll-data.d.ts +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/input-shims-c738363e.js +0 -4
- package/dist/ionic/p-c254bde2.js +0 -4
- package/dist/ionic/p-f58cbf92.system.js +0 -4
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { g as getScrollElement, c as scrollByPoint, a as findClosestIonContent } from './index8.js';
|
|
5
5
|
import { a as addEventListener, b as removeEventListener, r as raf, c as componentOnReady } from './helpers.js';
|
|
6
6
|
import { a as KeyboardResize, K as Keyboard } from './keyboard.js';
|
|
7
|
+
import { w as win } from './index5.js';
|
|
7
8
|
|
|
8
9
|
const cloneMap = new WeakMap();
|
|
9
10
|
const relocateInput = (componentEl, inputEl, shouldRelocate, inputRelativeY = 0, disabledClonedInput = false) => {
|
|
@@ -150,11 +151,10 @@ const enableInputBlurring = () => {
|
|
|
150
151
|
};
|
|
151
152
|
|
|
152
153
|
const SCROLL_ASSIST_SPEED = 0.3;
|
|
153
|
-
const getScrollData = (componentEl, contentEl, keyboardHeight) => {
|
|
154
|
+
const getScrollData = (componentEl, contentEl, keyboardHeight, platformHeight) => {
|
|
154
155
|
var _a;
|
|
155
156
|
const itemEl = (_a = componentEl.closest('ion-item,[ion-item]')) !== null && _a !== void 0 ? _a : componentEl;
|
|
156
|
-
return calcScrollData(itemEl.getBoundingClientRect(), contentEl.getBoundingClientRect(), keyboardHeight,
|
|
157
|
-
);
|
|
157
|
+
return calcScrollData(itemEl.getBoundingClientRect(), contentEl.getBoundingClientRect(), keyboardHeight, platformHeight);
|
|
158
158
|
};
|
|
159
159
|
const calcScrollData = (inputRect, contentRect, keyboardHeight, platformHeight) => {
|
|
160
160
|
// compute input's Y values relative to the body
|
|
@@ -254,67 +254,19 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
254
254
|
*/
|
|
255
255
|
const addScrollPadding = enableScrollPadding && (keyboardResize === undefined || keyboardResize.mode === KeyboardResize.None);
|
|
256
256
|
/**
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* a different focused text field.
|
|
262
|
-
*/
|
|
263
|
-
let hasKeyboardBeenPresentedForTextField = false;
|
|
264
|
-
/**
|
|
265
|
-
* Scroll assist is run when a text field
|
|
266
|
-
* is focused. However, it may need to
|
|
267
|
-
* re-run when the keyboard size changes
|
|
268
|
-
* such that the text field is now hidden
|
|
269
|
-
* underneath the keyboard.
|
|
270
|
-
* This function re-runs scroll assist
|
|
271
|
-
* when that happens.
|
|
257
|
+
* When adding scroll padding we need to know
|
|
258
|
+
* how much of the viewport the keyboard obscures.
|
|
259
|
+
* We do this by subtracting the keyboard height
|
|
260
|
+
* from the platform height.
|
|
272
261
|
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
* This should not be a problem when running in Cordova/Capacitor
|
|
280
|
-
* because `ionKeyboardDidShow` uses the native events
|
|
281
|
-
* which fire every time the keyboard changes.
|
|
282
|
-
*/
|
|
283
|
-
const keyboardShow = (ev) => {
|
|
284
|
-
/**
|
|
285
|
-
* If the keyboard has not yet been presented
|
|
286
|
-
* for this text field then the text field has just
|
|
287
|
-
* received focus. In that case, the focusin listener
|
|
288
|
-
* will run scroll assist.
|
|
289
|
-
*/
|
|
290
|
-
if (hasKeyboardBeenPresentedForTextField === false) {
|
|
291
|
-
hasKeyboardBeenPresentedForTextField = true;
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Otherwise, the keyboard has already been presented
|
|
296
|
-
* for the focused text field.
|
|
297
|
-
* This means that the keyboard likely changed
|
|
298
|
-
* geometry, and we need to re-run scroll assist.
|
|
299
|
-
* This can happen when the user rotates their device
|
|
300
|
-
* or when they switch keyboards.
|
|
301
|
-
*
|
|
302
|
-
* Make sure we pass in the computed keyboard height
|
|
303
|
-
* rather than the estimated keyboard height.
|
|
304
|
-
*
|
|
305
|
-
* Since the keyboard is already open then we do not
|
|
306
|
-
* need to wait for the webview to resize, so we pass
|
|
307
|
-
* "waitForResize: false".
|
|
308
|
-
*/
|
|
309
|
-
jsSetFocus(componentEl, inputEl, contentEl, footerEl, ev.detail.keyboardHeight, addScrollPadding, disableClonedInput, false);
|
|
310
|
-
};
|
|
311
|
-
/**
|
|
312
|
-
* Reset the internal state when the text field loses focus.
|
|
262
|
+
* If we compute this value when switching between
|
|
263
|
+
* inputs then the webview may already be resized.
|
|
264
|
+
* At this point, `win.innerHeight` has already accounted
|
|
265
|
+
* for the keyboard meaning we would then subtract
|
|
266
|
+
* the keyboard height again. This will result in the input
|
|
267
|
+
* being scrolled more than it needs to.
|
|
313
268
|
*/
|
|
314
|
-
const
|
|
315
|
-
hasKeyboardBeenPresentedForTextField = false;
|
|
316
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
317
|
-
};
|
|
269
|
+
const platformHeight = win !== undefined ? win.innerHeight : 0;
|
|
318
270
|
/**
|
|
319
271
|
* When the input is about to receive
|
|
320
272
|
* focus, we need to move it to prevent
|
|
@@ -331,23 +283,11 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
331
283
|
inputEl.removeAttribute(SKIP_SCROLL_ASSIST);
|
|
332
284
|
return;
|
|
333
285
|
}
|
|
334
|
-
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput);
|
|
335
|
-
/**
|
|
336
|
-
* Listen for any changes to the keyboard
|
|
337
|
-
* dimensions in case we need to re-run scroll assist.
|
|
338
|
-
*/
|
|
339
|
-
window.addEventListener('ionKeyboardDidShow', keyboardShow);
|
|
340
|
-
componentEl.addEventListener('focusout', focusOut, true);
|
|
286
|
+
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput, platformHeight);
|
|
341
287
|
};
|
|
342
288
|
componentEl.addEventListener('focusin', focusIn, true);
|
|
343
|
-
/**
|
|
344
|
-
* Scroll assist is being destroyed for this
|
|
345
|
-
* text field instance, so remove any remaining listeners.
|
|
346
|
-
*/
|
|
347
289
|
return () => {
|
|
348
290
|
componentEl.removeEventListener('focusin', focusIn, true);
|
|
349
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
350
|
-
componentEl.removeEventListener('focusout', focusOut, true);
|
|
351
291
|
};
|
|
352
292
|
};
|
|
353
293
|
/**
|
|
@@ -366,11 +306,11 @@ const setManualFocus = (el) => {
|
|
|
366
306
|
el.setAttribute(SKIP_SCROLL_ASSIST, 'true');
|
|
367
307
|
el.focus();
|
|
368
308
|
};
|
|
369
|
-
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false,
|
|
309
|
+
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false, platformHeight = 0) => {
|
|
370
310
|
if (!contentEl && !footerEl) {
|
|
371
311
|
return;
|
|
372
312
|
}
|
|
373
|
-
const scrollData = getScrollData(componentEl, (contentEl || footerEl), keyboardHeight);
|
|
313
|
+
const scrollData = getScrollData(componentEl, (contentEl || footerEl), keyboardHeight, platformHeight);
|
|
374
314
|
if (contentEl && Math.abs(scrollData.scrollAmount) < 4) {
|
|
375
315
|
// the text input is in a safe position that doesn't
|
|
376
316
|
// require it to be scrolled into view, just set focus now
|
|
@@ -457,7 +397,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
457
397
|
* bandwidth to become available.
|
|
458
398
|
*/
|
|
459
399
|
const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
460
|
-
if (
|
|
400
|
+
if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
461
401
|
/**
|
|
462
402
|
* On iOS devices, the system will show a "Passwords" bar above the keyboard
|
|
463
403
|
* after the initial keyboard is shown. This prevents the webview from resizing
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
const index = require('./index-10873539.js');
|
|
7
7
|
const helpers = require('./helpers-ea4ccbcb.js');
|
|
8
8
|
const keyboard = require('./keyboard-fd7db491.js');
|
|
9
|
+
const index$1 = require('./index-306a7476.js');
|
|
9
10
|
require('./index-cc7dfb7c.js');
|
|
10
11
|
require('./capacitor-2ffba62a.js');
|
|
11
|
-
require('./index-306a7476.js');
|
|
12
12
|
|
|
13
13
|
const cloneMap = new WeakMap();
|
|
14
14
|
const relocateInput = (componentEl, inputEl, shouldRelocate, inputRelativeY = 0, disabledClonedInput = false) => {
|
|
@@ -155,11 +155,10 @@ const enableInputBlurring = () => {
|
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
const SCROLL_ASSIST_SPEED = 0.3;
|
|
158
|
-
const getScrollData = (componentEl, contentEl, keyboardHeight) => {
|
|
158
|
+
const getScrollData = (componentEl, contentEl, keyboardHeight, platformHeight) => {
|
|
159
159
|
var _a;
|
|
160
160
|
const itemEl = (_a = componentEl.closest('ion-item,[ion-item]')) !== null && _a !== void 0 ? _a : componentEl;
|
|
161
|
-
return calcScrollData(itemEl.getBoundingClientRect(), contentEl.getBoundingClientRect(), keyboardHeight,
|
|
162
|
-
);
|
|
161
|
+
return calcScrollData(itemEl.getBoundingClientRect(), contentEl.getBoundingClientRect(), keyboardHeight, platformHeight);
|
|
163
162
|
};
|
|
164
163
|
const calcScrollData = (inputRect, contentRect, keyboardHeight, platformHeight) => {
|
|
165
164
|
// compute input's Y values relative to the body
|
|
@@ -259,67 +258,19 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
259
258
|
*/
|
|
260
259
|
const addScrollPadding = enableScrollPadding && (keyboardResize === undefined || keyboardResize.mode === keyboard.KeyboardResize.None);
|
|
261
260
|
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
* a different focused text field.
|
|
267
|
-
*/
|
|
268
|
-
let hasKeyboardBeenPresentedForTextField = false;
|
|
269
|
-
/**
|
|
270
|
-
* Scroll assist is run when a text field
|
|
271
|
-
* is focused. However, it may need to
|
|
272
|
-
* re-run when the keyboard size changes
|
|
273
|
-
* such that the text field is now hidden
|
|
274
|
-
* underneath the keyboard.
|
|
275
|
-
* This function re-runs scroll assist
|
|
276
|
-
* when that happens.
|
|
261
|
+
* When adding scroll padding we need to know
|
|
262
|
+
* how much of the viewport the keyboard obscures.
|
|
263
|
+
* We do this by subtracting the keyboard height
|
|
264
|
+
* from the platform height.
|
|
277
265
|
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* This should not be a problem when running in Cordova/Capacitor
|
|
285
|
-
* because `ionKeyboardDidShow` uses the native events
|
|
286
|
-
* which fire every time the keyboard changes.
|
|
287
|
-
*/
|
|
288
|
-
const keyboardShow = (ev) => {
|
|
289
|
-
/**
|
|
290
|
-
* If the keyboard has not yet been presented
|
|
291
|
-
* for this text field then the text field has just
|
|
292
|
-
* received focus. In that case, the focusin listener
|
|
293
|
-
* will run scroll assist.
|
|
294
|
-
*/
|
|
295
|
-
if (hasKeyboardBeenPresentedForTextField === false) {
|
|
296
|
-
hasKeyboardBeenPresentedForTextField = true;
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Otherwise, the keyboard has already been presented
|
|
301
|
-
* for the focused text field.
|
|
302
|
-
* This means that the keyboard likely changed
|
|
303
|
-
* geometry, and we need to re-run scroll assist.
|
|
304
|
-
* This can happen when the user rotates their device
|
|
305
|
-
* or when they switch keyboards.
|
|
306
|
-
*
|
|
307
|
-
* Make sure we pass in the computed keyboard height
|
|
308
|
-
* rather than the estimated keyboard height.
|
|
309
|
-
*
|
|
310
|
-
* Since the keyboard is already open then we do not
|
|
311
|
-
* need to wait for the webview to resize, so we pass
|
|
312
|
-
* "waitForResize: false".
|
|
313
|
-
*/
|
|
314
|
-
jsSetFocus(componentEl, inputEl, contentEl, footerEl, ev.detail.keyboardHeight, addScrollPadding, disableClonedInput, false);
|
|
315
|
-
};
|
|
316
|
-
/**
|
|
317
|
-
* Reset the internal state when the text field loses focus.
|
|
266
|
+
* If we compute this value when switching between
|
|
267
|
+
* inputs then the webview may already be resized.
|
|
268
|
+
* At this point, `win.innerHeight` has already accounted
|
|
269
|
+
* for the keyboard meaning we would then subtract
|
|
270
|
+
* the keyboard height again. This will result in the input
|
|
271
|
+
* being scrolled more than it needs to.
|
|
318
272
|
*/
|
|
319
|
-
const
|
|
320
|
-
hasKeyboardBeenPresentedForTextField = false;
|
|
321
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
322
|
-
};
|
|
273
|
+
const platformHeight = index$1.win !== undefined ? index$1.win.innerHeight : 0;
|
|
323
274
|
/**
|
|
324
275
|
* When the input is about to receive
|
|
325
276
|
* focus, we need to move it to prevent
|
|
@@ -336,23 +287,11 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
336
287
|
inputEl.removeAttribute(SKIP_SCROLL_ASSIST);
|
|
337
288
|
return;
|
|
338
289
|
}
|
|
339
|
-
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput);
|
|
340
|
-
/**
|
|
341
|
-
* Listen for any changes to the keyboard
|
|
342
|
-
* dimensions in case we need to re-run scroll assist.
|
|
343
|
-
*/
|
|
344
|
-
window.addEventListener('ionKeyboardDidShow', keyboardShow);
|
|
345
|
-
componentEl.addEventListener('focusout', focusOut, true);
|
|
290
|
+
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput, platformHeight);
|
|
346
291
|
};
|
|
347
292
|
componentEl.addEventListener('focusin', focusIn, true);
|
|
348
|
-
/**
|
|
349
|
-
* Scroll assist is being destroyed for this
|
|
350
|
-
* text field instance, so remove any remaining listeners.
|
|
351
|
-
*/
|
|
352
293
|
return () => {
|
|
353
294
|
componentEl.removeEventListener('focusin', focusIn, true);
|
|
354
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
355
|
-
componentEl.removeEventListener('focusout', focusOut, true);
|
|
356
295
|
};
|
|
357
296
|
};
|
|
358
297
|
/**
|
|
@@ -371,11 +310,11 @@ const setManualFocus = (el) => {
|
|
|
371
310
|
el.setAttribute(SKIP_SCROLL_ASSIST, 'true');
|
|
372
311
|
el.focus();
|
|
373
312
|
};
|
|
374
|
-
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false,
|
|
313
|
+
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false, platformHeight = 0) => {
|
|
375
314
|
if (!contentEl && !footerEl) {
|
|
376
315
|
return;
|
|
377
316
|
}
|
|
378
|
-
const scrollData = getScrollData(componentEl, (contentEl || footerEl), keyboardHeight);
|
|
317
|
+
const scrollData = getScrollData(componentEl, (contentEl || footerEl), keyboardHeight, platformHeight);
|
|
379
318
|
if (contentEl && Math.abs(scrollData.scrollAmount) < 4) {
|
|
380
319
|
// the text input is in a safe position that doesn't
|
|
381
320
|
// require it to be scrolled into view, just set focus now
|
|
@@ -462,7 +401,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
462
401
|
* bandwidth to become available.
|
|
463
402
|
*/
|
|
464
403
|
const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
465
|
-
if (
|
|
404
|
+
if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
466
405
|
/**
|
|
467
406
|
* On iOS devices, the system will show a "Passwords" bar above the keyboard
|
|
468
407
|
* after the initial keyboard is shown. This prevents the webview from resizing
|
|
@@ -42,7 +42,7 @@ const App = class {
|
|
|
42
42
|
* platforms proceed into this block.
|
|
43
43
|
*/
|
|
44
44
|
const platform = ionicGlobal.isPlatform(window, 'ios') ? 'ios' : 'android';
|
|
45
|
-
Promise.resolve().then(function () { return require('./input-shims-
|
|
45
|
+
Promise.resolve().then(function () { return require('./input-shims-93284c80.js'); }).then((module) => module.startInputShims(ionicGlobal.config, platform));
|
|
46
46
|
}
|
|
47
47
|
const hardwareBackButtonModule = await Promise.resolve().then(function () { return require('./hardware-back-button-b67c8e75.js'); });
|
|
48
48
|
if (ionicGlobal.config.getBoolean('hardwareBackButton', isHybrid)) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* (C) Ionic http://ionicframework.com - MIT License
|
|
3
3
|
*/
|
|
4
|
+
import { win } from "../../browser/index";
|
|
4
5
|
import { getScrollElement, scrollByPoint } from "../../content";
|
|
5
6
|
import { raf } from "../../helpers";
|
|
6
7
|
import { KeyboardResize } from "../../native/keyboard";
|
|
@@ -21,67 +22,19 @@ export const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, ke
|
|
|
21
22
|
*/
|
|
22
23
|
const addScrollPadding = enableScrollPadding && (keyboardResize === undefined || keyboardResize.mode === KeyboardResize.None);
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* a different focused text field.
|
|
29
|
-
*/
|
|
30
|
-
let hasKeyboardBeenPresentedForTextField = false;
|
|
31
|
-
/**
|
|
32
|
-
* Scroll assist is run when a text field
|
|
33
|
-
* is focused. However, it may need to
|
|
34
|
-
* re-run when the keyboard size changes
|
|
35
|
-
* such that the text field is now hidden
|
|
36
|
-
* underneath the keyboard.
|
|
37
|
-
* This function re-runs scroll assist
|
|
38
|
-
* when that happens.
|
|
25
|
+
* When adding scroll padding we need to know
|
|
26
|
+
* how much of the viewport the keyboard obscures.
|
|
27
|
+
* We do this by subtracting the keyboard height
|
|
28
|
+
* from the platform height.
|
|
39
29
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* This should not be a problem when running in Cordova/Capacitor
|
|
47
|
-
* because `ionKeyboardDidShow` uses the native events
|
|
48
|
-
* which fire every time the keyboard changes.
|
|
49
|
-
*/
|
|
50
|
-
const keyboardShow = (ev) => {
|
|
51
|
-
/**
|
|
52
|
-
* If the keyboard has not yet been presented
|
|
53
|
-
* for this text field then the text field has just
|
|
54
|
-
* received focus. In that case, the focusin listener
|
|
55
|
-
* will run scroll assist.
|
|
56
|
-
*/
|
|
57
|
-
if (hasKeyboardBeenPresentedForTextField === false) {
|
|
58
|
-
hasKeyboardBeenPresentedForTextField = true;
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Otherwise, the keyboard has already been presented
|
|
63
|
-
* for the focused text field.
|
|
64
|
-
* This means that the keyboard likely changed
|
|
65
|
-
* geometry, and we need to re-run scroll assist.
|
|
66
|
-
* This can happen when the user rotates their device
|
|
67
|
-
* or when they switch keyboards.
|
|
68
|
-
*
|
|
69
|
-
* Make sure we pass in the computed keyboard height
|
|
70
|
-
* rather than the estimated keyboard height.
|
|
71
|
-
*
|
|
72
|
-
* Since the keyboard is already open then we do not
|
|
73
|
-
* need to wait for the webview to resize, so we pass
|
|
74
|
-
* "waitForResize: false".
|
|
75
|
-
*/
|
|
76
|
-
jsSetFocus(componentEl, inputEl, contentEl, footerEl, ev.detail.keyboardHeight, addScrollPadding, disableClonedInput, false);
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Reset the internal state when the text field loses focus.
|
|
30
|
+
* If we compute this value when switching between
|
|
31
|
+
* inputs then the webview may already be resized.
|
|
32
|
+
* At this point, `win.innerHeight` has already accounted
|
|
33
|
+
* for the keyboard meaning we would then subtract
|
|
34
|
+
* the keyboard height again. This will result in the input
|
|
35
|
+
* being scrolled more than it needs to.
|
|
80
36
|
*/
|
|
81
|
-
const
|
|
82
|
-
hasKeyboardBeenPresentedForTextField = false;
|
|
83
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
84
|
-
};
|
|
37
|
+
const platformHeight = win !== undefined ? win.innerHeight : 0;
|
|
85
38
|
/**
|
|
86
39
|
* When the input is about to receive
|
|
87
40
|
* focus, we need to move it to prevent
|
|
@@ -98,23 +51,11 @@ export const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, ke
|
|
|
98
51
|
inputEl.removeAttribute(SKIP_SCROLL_ASSIST);
|
|
99
52
|
return;
|
|
100
53
|
}
|
|
101
|
-
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput);
|
|
102
|
-
/**
|
|
103
|
-
* Listen for any changes to the keyboard
|
|
104
|
-
* dimensions in case we need to re-run scroll assist.
|
|
105
|
-
*/
|
|
106
|
-
window.addEventListener('ionKeyboardDidShow', keyboardShow);
|
|
107
|
-
componentEl.addEventListener('focusout', focusOut, true);
|
|
54
|
+
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput, platformHeight);
|
|
108
55
|
};
|
|
109
56
|
componentEl.addEventListener('focusin', focusIn, true);
|
|
110
|
-
/**
|
|
111
|
-
* Scroll assist is being destroyed for this
|
|
112
|
-
* text field instance, so remove any remaining listeners.
|
|
113
|
-
*/
|
|
114
57
|
return () => {
|
|
115
58
|
componentEl.removeEventListener('focusin', focusIn, true);
|
|
116
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
117
|
-
componentEl.removeEventListener('focusout', focusOut, true);
|
|
118
59
|
};
|
|
119
60
|
};
|
|
120
61
|
/**
|
|
@@ -133,11 +74,11 @@ const setManualFocus = (el) => {
|
|
|
133
74
|
el.setAttribute(SKIP_SCROLL_ASSIST, 'true');
|
|
134
75
|
el.focus();
|
|
135
76
|
};
|
|
136
|
-
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false,
|
|
77
|
+
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false, platformHeight = 0) => {
|
|
137
78
|
if (!contentEl && !footerEl) {
|
|
138
79
|
return;
|
|
139
80
|
}
|
|
140
|
-
const scrollData = getScrollData(componentEl, (contentEl || footerEl), keyboardHeight);
|
|
81
|
+
const scrollData = getScrollData(componentEl, (contentEl || footerEl), keyboardHeight, platformHeight);
|
|
141
82
|
if (contentEl && Math.abs(scrollData.scrollAmount) < 4) {
|
|
142
83
|
// the text input is in a safe position that doesn't
|
|
143
84
|
// require it to be scrolled into view, just set focus now
|
|
@@ -224,7 +165,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
224
165
|
* bandwidth to become available.
|
|
225
166
|
*/
|
|
226
167
|
const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
227
|
-
if (
|
|
168
|
+
if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
228
169
|
/**
|
|
229
170
|
* On iOS devices, the system will show a "Passwords" bar above the keyboard
|
|
230
171
|
* after the initial keyboard is shown. This prevents the webview from resizing
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { SCROLL_AMOUNT_PADDING } from "./common";
|
|
5
5
|
const SCROLL_ASSIST_SPEED = 0.3;
|
|
6
|
-
export const getScrollData = (componentEl, contentEl, keyboardHeight) => {
|
|
6
|
+
export const getScrollData = (componentEl, contentEl, keyboardHeight, platformHeight) => {
|
|
7
7
|
var _a;
|
|
8
8
|
const itemEl = (_a = componentEl.closest('ion-item,[ion-item]')) !== null && _a !== void 0 ? _a : componentEl;
|
|
9
|
-
return calcScrollData(itemEl.getBoundingClientRect(), contentEl.getBoundingClientRect(), keyboardHeight,
|
|
10
|
-
);
|
|
9
|
+
return calcScrollData(itemEl.getBoundingClientRect(), contentEl.getBoundingClientRect(), keyboardHeight, platformHeight);
|
|
11
10
|
};
|
|
12
11
|
const calcScrollData = (inputRect, contentRect, keyboardHeight, platformHeight) => {
|
|
13
12
|
// compute input's Y values relative to the body
|
package/dist/docs.json
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
import { g as getScrollElement, c as scrollByPoint, f as findClosestIonContent } from './index-746a238e.js';
|
|
5
5
|
import { a as addEventListener, b as removeEventListener, r as raf, c as componentOnReady } from './helpers-3379ba19.js';
|
|
6
6
|
import { a as KeyboardResize, K as Keyboard } from './keyboard-b063f012.js';
|
|
7
|
+
import { w as win } from './index-7a14ecec.js';
|
|
7
8
|
import './index-595d62c9.js';
|
|
8
9
|
import './capacitor-b4979570.js';
|
|
9
|
-
import './index-7a14ecec.js';
|
|
10
10
|
|
|
11
11
|
const cloneMap = new WeakMap();
|
|
12
12
|
const relocateInput = (componentEl, inputEl, shouldRelocate, inputRelativeY = 0, disabledClonedInput = false) => {
|
|
@@ -153,11 +153,10 @@ const enableInputBlurring = () => {
|
|
|
153
153
|
};
|
|
154
154
|
|
|
155
155
|
const SCROLL_ASSIST_SPEED = 0.3;
|
|
156
|
-
const getScrollData = (componentEl, contentEl, keyboardHeight) => {
|
|
156
|
+
const getScrollData = (componentEl, contentEl, keyboardHeight, platformHeight) => {
|
|
157
157
|
var _a;
|
|
158
158
|
const itemEl = (_a = componentEl.closest('ion-item,[ion-item]')) !== null && _a !== void 0 ? _a : componentEl;
|
|
159
|
-
return calcScrollData(itemEl.getBoundingClientRect(), contentEl.getBoundingClientRect(), keyboardHeight,
|
|
160
|
-
);
|
|
159
|
+
return calcScrollData(itemEl.getBoundingClientRect(), contentEl.getBoundingClientRect(), keyboardHeight, platformHeight);
|
|
161
160
|
};
|
|
162
161
|
const calcScrollData = (inputRect, contentRect, keyboardHeight, platformHeight) => {
|
|
163
162
|
// compute input's Y values relative to the body
|
|
@@ -257,67 +256,19 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
257
256
|
*/
|
|
258
257
|
const addScrollPadding = enableScrollPadding && (keyboardResize === undefined || keyboardResize.mode === KeyboardResize.None);
|
|
259
258
|
/**
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
* a different focused text field.
|
|
265
|
-
*/
|
|
266
|
-
let hasKeyboardBeenPresentedForTextField = false;
|
|
267
|
-
/**
|
|
268
|
-
* Scroll assist is run when a text field
|
|
269
|
-
* is focused. However, it may need to
|
|
270
|
-
* re-run when the keyboard size changes
|
|
271
|
-
* such that the text field is now hidden
|
|
272
|
-
* underneath the keyboard.
|
|
273
|
-
* This function re-runs scroll assist
|
|
274
|
-
* when that happens.
|
|
259
|
+
* When adding scroll padding we need to know
|
|
260
|
+
* how much of the viewport the keyboard obscures.
|
|
261
|
+
* We do this by subtracting the keyboard height
|
|
262
|
+
* from the platform height.
|
|
275
263
|
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* This should not be a problem when running in Cordova/Capacitor
|
|
283
|
-
* because `ionKeyboardDidShow` uses the native events
|
|
284
|
-
* which fire every time the keyboard changes.
|
|
285
|
-
*/
|
|
286
|
-
const keyboardShow = (ev) => {
|
|
287
|
-
/**
|
|
288
|
-
* If the keyboard has not yet been presented
|
|
289
|
-
* for this text field then the text field has just
|
|
290
|
-
* received focus. In that case, the focusin listener
|
|
291
|
-
* will run scroll assist.
|
|
292
|
-
*/
|
|
293
|
-
if (hasKeyboardBeenPresentedForTextField === false) {
|
|
294
|
-
hasKeyboardBeenPresentedForTextField = true;
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Otherwise, the keyboard has already been presented
|
|
299
|
-
* for the focused text field.
|
|
300
|
-
* This means that the keyboard likely changed
|
|
301
|
-
* geometry, and we need to re-run scroll assist.
|
|
302
|
-
* This can happen when the user rotates their device
|
|
303
|
-
* or when they switch keyboards.
|
|
304
|
-
*
|
|
305
|
-
* Make sure we pass in the computed keyboard height
|
|
306
|
-
* rather than the estimated keyboard height.
|
|
307
|
-
*
|
|
308
|
-
* Since the keyboard is already open then we do not
|
|
309
|
-
* need to wait for the webview to resize, so we pass
|
|
310
|
-
* "waitForResize: false".
|
|
311
|
-
*/
|
|
312
|
-
jsSetFocus(componentEl, inputEl, contentEl, footerEl, ev.detail.keyboardHeight, addScrollPadding, disableClonedInput, false);
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* Reset the internal state when the text field loses focus.
|
|
264
|
+
* If we compute this value when switching between
|
|
265
|
+
* inputs then the webview may already be resized.
|
|
266
|
+
* At this point, `win.innerHeight` has already accounted
|
|
267
|
+
* for the keyboard meaning we would then subtract
|
|
268
|
+
* the keyboard height again. This will result in the input
|
|
269
|
+
* being scrolled more than it needs to.
|
|
316
270
|
*/
|
|
317
|
-
const
|
|
318
|
-
hasKeyboardBeenPresentedForTextField = false;
|
|
319
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
320
|
-
};
|
|
271
|
+
const platformHeight = win !== undefined ? win.innerHeight : 0;
|
|
321
272
|
/**
|
|
322
273
|
* When the input is about to receive
|
|
323
274
|
* focus, we need to move it to prevent
|
|
@@ -334,23 +285,11 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
334
285
|
inputEl.removeAttribute(SKIP_SCROLL_ASSIST);
|
|
335
286
|
return;
|
|
336
287
|
}
|
|
337
|
-
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput);
|
|
338
|
-
/**
|
|
339
|
-
* Listen for any changes to the keyboard
|
|
340
|
-
* dimensions in case we need to re-run scroll assist.
|
|
341
|
-
*/
|
|
342
|
-
window.addEventListener('ionKeyboardDidShow', keyboardShow);
|
|
343
|
-
componentEl.addEventListener('focusout', focusOut, true);
|
|
288
|
+
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput, platformHeight);
|
|
344
289
|
};
|
|
345
290
|
componentEl.addEventListener('focusin', focusIn, true);
|
|
346
|
-
/**
|
|
347
|
-
* Scroll assist is being destroyed for this
|
|
348
|
-
* text field instance, so remove any remaining listeners.
|
|
349
|
-
*/
|
|
350
291
|
return () => {
|
|
351
292
|
componentEl.removeEventListener('focusin', focusIn, true);
|
|
352
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
353
|
-
componentEl.removeEventListener('focusout', focusOut, true);
|
|
354
293
|
};
|
|
355
294
|
};
|
|
356
295
|
/**
|
|
@@ -369,11 +308,11 @@ const setManualFocus = (el) => {
|
|
|
369
308
|
el.setAttribute(SKIP_SCROLL_ASSIST, 'true');
|
|
370
309
|
el.focus();
|
|
371
310
|
};
|
|
372
|
-
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false,
|
|
311
|
+
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false, platformHeight = 0) => {
|
|
373
312
|
if (!contentEl && !footerEl) {
|
|
374
313
|
return;
|
|
375
314
|
}
|
|
376
|
-
const scrollData = getScrollData(componentEl, (contentEl || footerEl), keyboardHeight);
|
|
315
|
+
const scrollData = getScrollData(componentEl, (contentEl || footerEl), keyboardHeight, platformHeight);
|
|
377
316
|
if (contentEl && Math.abs(scrollData.scrollAmount) < 4) {
|
|
378
317
|
// the text input is in a safe position that doesn't
|
|
379
318
|
// require it to be scrolled into view, just set focus now
|
|
@@ -460,7 +399,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
460
399
|
* bandwidth to become available.
|
|
461
400
|
*/
|
|
462
401
|
const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
463
|
-
if (
|
|
402
|
+
if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
464
403
|
/**
|
|
465
404
|
* On iOS devices, the system will show a "Passwords" bar above the keyboard
|
|
466
405
|
* after the initial keyboard is shown. This prevents the webview from resizing
|
|
@@ -38,7 +38,7 @@ const App = class {
|
|
|
38
38
|
* platforms proceed into this block.
|
|
39
39
|
*/
|
|
40
40
|
const platform = isPlatform(window, 'ios') ? 'ios' : 'android';
|
|
41
|
-
import('./input-shims-
|
|
41
|
+
import('./input-shims-4f1b0af9.js').then((module) => module.startInputShims(config, platform));
|
|
42
42
|
}
|
|
43
43
|
const hardwareBackButtonModule = await import('./hardware-back-button-39299f84.js');
|
|
44
44
|
if (config.getBoolean('hardwareBackButton', isHybrid)) {
|