Commit d57aae18 authored by xiaohuoni's avatar xiaohuoni Committed by 陈帅

fix slide hidden Header bug (#2681)

* fix slide  hidden Header bug

Close :#2680

* Prevent repeated animation
parent bd0e5ae1
...@@ -93,13 +93,12 @@ class HeaderView extends PureComponent { ...@@ -93,13 +93,12 @@ class HeaderView extends PureComponent {
} }
const scrollTop = document.body.scrollTop + document.documentElement.scrollTop; const scrollTop = document.body.scrollTop + document.documentElement.scrollTop;
if (!this.ticking) { if (!this.ticking) {
this.ticking = true;
requestAnimationFrame(() => { requestAnimationFrame(() => {
if (this.oldScrollTop > scrollTop) { if (this.oldScrollTop > scrollTop) {
this.setState({ this.setState({
visible: true, visible: true,
}); });
this.scrollTop = scrollTop;
return;
} }
if (scrollTop > 300 && visible) { if (scrollTop > 300 && visible) {
this.setState({ this.setState({
...@@ -115,7 +114,6 @@ class HeaderView extends PureComponent { ...@@ -115,7 +114,6 @@ class HeaderView extends PureComponent {
this.ticking = false; this.ticking = false;
}); });
} }
this.ticking = false;
}; };
render() { render() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment