Skip to content

Commit

Permalink
Merge branch 'fix-pull'
Browse files Browse the repository at this point in the history
  • Loading branch information
edison-hm committed Jul 9, 2020
2 parents f2c297a + c594a79 commit f6cc5c4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
4 changes: 1 addition & 3 deletions components/mask/demo.md
Expand Up @@ -10,9 +10,7 @@ import { Cell, Button, Mask } from 'zarm';
const Demo = () => {
const [visible, setVisible] = useState(false);

const toggle = () => {
setVisible(!visible);
};
const toggle = () => setVisible(!visible);

return (
<>
Expand Down
14 changes: 10 additions & 4 deletions components/pull/Pull.tsx
Expand Up @@ -103,7 +103,7 @@ export default class Pull extends PureComponent<PullProps, any> {
wrapTouchmove = (event) => {
const touch = event.touches[0];
const currentY = touch.pageY;
if (currentY - this.wrapTouchstartY > 0 && event.cancelable && this.wrap.scrollTop === 0) {
if (currentY - this.wrapTouchstartY > 0 && event.cancelable && this.getWrapScrollTop() === 0) {
event.preventDefault();
}
};
Expand All @@ -112,6 +112,11 @@ export default class Pull extends PureComponent<PullProps, any> {
this.wrapTouchstartY = 0;
};

getWrapScrollTop = () => {
const el = (this.wrap === document.documentElement) ? (document.scrollingElement || document.documentElement) : this.wrap;
return el.scrollTop;
};

getScrollContainer = () => {
return ((node) => {
while (node && node.parentNode && node.parentNode !== document.body) {
Expand All @@ -127,6 +132,7 @@ export default class Pull extends PureComponent<PullProps, any> {
node = node.parentNode;
}
})(this.pull) || document.documentElement;
// 由于在ios12版本中,document.scrollingElement.clientHeight计算结果与document.documentElement.clientHeight不一致,故无法替换。
};

addScrollEvent = () => {
Expand All @@ -137,7 +143,7 @@ export default class Pull extends PureComponent<PullProps, any> {

onScroll = () => {
const { refreshState, loadState } = this.state;
const { scrollHeight, scrollTop, clientHeight } = this.wrap;
const { scrollHeight, clientHeight } = this.wrap;
const load: PullAction = { ...Pull.defaultProps.load, ...this.props.load };
const { handler, distance } = load;

Expand All @@ -148,7 +154,7 @@ export default class Pull extends PureComponent<PullProps, any> {
|| scrollHeight <= clientHeight

// 内容高度 - 偏移值 - 修正距离 <= 容器可见高度
|| scrollHeight - (scrollTop + document.body.scrollTop) - distance! > clientHeight
|| scrollHeight - this.getWrapScrollTop() - distance! > clientHeight
) {
return;
}
Expand All @@ -165,7 +171,7 @@ export default class Pull extends PureComponent<PullProps, any> {
|| offsetY <= 0

// 未滚动到顶部
|| (offsetY > 0 && (this.wrap.scrollTop + document.body.scrollTop) > 0)
|| (offsetY > 0 && this.getWrapScrollTop() > 0)

// 已经触发过加载状态
|| this.state.refreshState >= REFRESH_STATE.loading
Expand Down
7 changes: 5 additions & 2 deletions site/web/components/Markdown/style.scss
Expand Up @@ -34,12 +34,15 @@

pre {
margin: 0;
padding: 16px;
overflow: auto;
font-size: 14px;
line-height: 1.5;
background-color: #f6f8fa;
border-radius: 3px;

code {
padding: 1em;
}
}

h1,
Expand Down Expand Up @@ -73,8 +76,8 @@

code {
background-color: #f1f1f1;
padding: 2px 6px;
margin: 0 1px;
padding: 2px 5px;
border-radius: 3px;
}

Expand Down
2 changes: 1 addition & 1 deletion site/web/pages/Components/index.jsx
Expand Up @@ -30,7 +30,7 @@ const Simulator = () => {
const params = useParams();
const simulatorRef = useRef();
const { lang } = useContext(Context);
const [affix, setAffix] = useState(true);
const [affix, setAffix] = useState(false);

const simulatorCls = classnames('simulator', {
'simulator--affix': affix,
Expand Down
5 changes: 5 additions & 0 deletions site/web/pages/Components/style.scss
Expand Up @@ -110,4 +110,9 @@
margin-left: 0;
}
}

.za-back-to-top {
right: 30px !important;
bottom: 30px !important;
}
}

0 comments on commit f6cc5c4

Please sign in to comment.