Commit 9d016cd9 by FE

srcoll modify

parent 4331b905
...@@ -78,8 +78,16 @@ class SearchResult extends PureComponent { ...@@ -78,8 +78,16 @@ class SearchResult extends PureComponent {
handleScroll = throttle(() => { handleScroll = throttle(() => {
let y = window.scrollY, let y = window.scrollY,
headY = this.searchHead.current.offsetTop; headY = this.searchHead.current.offsetTop;
console.log(headY,'headY');
console.log(document.querySelector('body').offsetHeight);
// 向上滑动
if (y < this.prevScrollY && y > 0) { if (y < this.prevScrollY && y > 0) {
console.log(0);
console.log(this.state.swipeDirection);
if (this.state.swipeDirection === this.swipeDown) { if (this.state.swipeDirection === this.swipeDown) {
console.log(1);
y <= headY && this.state.searchHeadStyle.position !== 'fixed' && y <= headY && this.state.searchHeadStyle.position !== 'fixed' &&
this.setState({ this.setState({
searchHeadStyle: { searchHeadStyle: {
...@@ -88,19 +96,27 @@ class SearchResult extends PureComponent { ...@@ -88,19 +96,27 @@ class SearchResult extends PureComponent {
} }
}) })
} else { } else {
console.log(2);
this.setState({ this.setState({
swipeDirection: this.swipeDown swipeDirection: this.swipeDown
}, () => { }, () => {
if (this.state.swipeDirection === this.swipeDown) { if (this.state.swipeDirection === this.swipeDown) {
this.setState({ let h = y > document.querySelector('body').offsetHeight? document.querySelector('body').offsetHeight: y;
searchHeadStyle: { let h1 = this.searchHead.current.offsetHeight
top: `${y > headY ? y - 44 : y}px` this.setState({
} searchHeadStyle: {
}) // top: `${h > headY ? h - h1 : h}px`
top: `${y}px`
}
})
} }
}) })
} }
} else { } else {
console.log(3);
this.state.swipeDirection !== this.swipeUp && this.state.swipeDirection !== this.swipeUp &&
this.setState({ this.setState({
swipeDirection: this.swipeUp, swipeDirection: this.swipeUp,
......
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