mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[improvement] extract resetScroll function (#3869)
This commit is contained in:
parent
cc445dfc00
commit
e653484f39
@ -2,9 +2,8 @@ import Icon from '../icon';
|
|||||||
import Cell from '../cell';
|
import Cell from '../cell';
|
||||||
import { cellProps } from '../cell/shared';
|
import { cellProps } from '../cell/shared';
|
||||||
import { preventDefault } from '../utils/dom/event';
|
import { preventDefault } from '../utils/dom/event';
|
||||||
import { getRootScrollTop, setRootScrollTop } from '../utils/dom/scroll';
|
import { resetScroll } from '../utils/dom/reset-scroll';
|
||||||
import { createNamespace, isObj, isDef, addUnit } from '../utils';
|
import { createNamespace, isObj, isDef, addUnit } from '../utils';
|
||||||
import { isIOS } from '../utils/validate/system';
|
|
||||||
|
|
||||||
const [createComponent, bem] = createNamespace('field');
|
const [createComponent, bem] = createNamespace('field');
|
||||||
|
|
||||||
@ -134,13 +133,7 @@ export default createComponent({
|
|||||||
onBlur(event) {
|
onBlur(event) {
|
||||||
this.focused = false;
|
this.focused = false;
|
||||||
this.$emit('blur', event);
|
this.$emit('blur', event);
|
||||||
|
resetScroll();
|
||||||
// Hack for iOS12 page scroll
|
|
||||||
// https://developers.weixin.qq.com/community/develop/doc/00044ae90742f8c82fb78fcae56800
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (isIOS()) {
|
|
||||||
setRootScrollTop(getRootScrollTop());
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { createNamespace, isDef, addUnit } from '../utils';
|
import { createNamespace, isDef, addUnit } from '../utils';
|
||||||
import { getRootScrollTop, setRootScrollTop } from '../utils/dom/scroll';
|
import { resetScroll } from '../utils/dom/reset-scroll';
|
||||||
import { isIOS } from '../utils/validate/system';
|
|
||||||
|
|
||||||
const [createComponent, bem] = createNamespace('stepper');
|
const [createComponent, bem] = createNamespace('stepper');
|
||||||
|
|
||||||
@ -156,12 +155,7 @@ export default createComponent({
|
|||||||
event.target.value = this.currentValue;
|
event.target.value = this.currentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hack for iOS12 page scroll
|
resetScroll();
|
||||||
// https://developers.weixin.qq.com/community/develop/doc/00044ae90742f8c82fb78fcae56800
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (isIOS()) {
|
|
||||||
setRootScrollTop(getRootScrollTop());
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
longPressStep() {
|
longPressStep() {
|
||||||
|
16
src/utils/dom/reset-scroll.ts
Normal file
16
src/utils/dom/reset-scroll.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* Hack for iOS12 page scroll
|
||||||
|
* https://developers.weixin.qq.com/community/develop/doc/00044ae90742f8c82fb78fcae56800
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { isIOS as checkIsIOS } from '../validate/system';
|
||||||
|
import { getRootScrollTop, setRootScrollTop } from './scroll';
|
||||||
|
|
||||||
|
const isIOS = checkIsIOS();
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
export function resetScroll() {
|
||||||
|
if (isIOS) {
|
||||||
|
setRootScrollTop(getRootScrollTop());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user