[improvement] extract resetScroll function (#3869)

This commit is contained in:
neverland 2019-07-16 20:56:22 +08:00 committed by GitHub
parent cc445dfc00
commit e653484f39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 17 deletions

View File

@ -2,9 +2,8 @@ import Icon from '../icon';
import Cell from '../cell';
import { cellProps } from '../cell/shared';
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 { isIOS } from '../utils/validate/system';
const [createComponent, bem] = createNamespace('field');
@ -134,13 +133,7 @@ export default createComponent({
onBlur(event) {
this.focused = false;
this.$emit('blur', event);
// Hack for iOS12 page scroll
// https://developers.weixin.qq.com/community/develop/doc/00044ae90742f8c82fb78fcae56800
/* istanbul ignore next */
if (isIOS()) {
setRootScrollTop(getRootScrollTop());
}
resetScroll();
},
onClick(event) {

View File

@ -1,6 +1,5 @@
import { createNamespace, isDef, addUnit } from '../utils';
import { getRootScrollTop, setRootScrollTop } from '../utils/dom/scroll';
import { isIOS } from '../utils/validate/system';
import { resetScroll } from '../utils/dom/reset-scroll';
const [createComponent, bem] = createNamespace('stepper');
@ -156,12 +155,7 @@ export default createComponent({
event.target.value = this.currentValue;
}
// Hack for iOS12 page scroll
// https://developers.weixin.qq.com/community/develop/doc/00044ae90742f8c82fb78fcae56800
/* istanbul ignore next */
if (isIOS()) {
setRootScrollTop(getRootScrollTop());
}
resetScroll();
},
longPressStep() {

View 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());
}
}