Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
baiguangyao
mr-julyedu
Commits
962decae
Commit
962decae
authored
Sep 10, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
搜索
parent
e3f4c090
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
29 deletions
+36
-29
src/components/search/search-result.js
+36
-29
No files found.
src/components/search/search-result.js
View file @
962decae
import
React
,
{
PureComponent
}
from
'react'
;
import
{
connect
}
from
'react-redux'
;
import
SearchHeader
from
'./searchHead'
import
VList
from
'@/common/VList'
import
{
http
,
getParam
}
from
'@/utils'
import
'./search-result.scss'
import
Recommendation
from
'./recommendation'
import
throttle
from
'lodash/throttle'
import
classnames
from
"classnames"
;
const
ForwardRefSearchHead
=
React
.
forwardRef
((
props
,
ref
)
=>
{
...
...
@@ -22,18 +20,19 @@ const Bottom = ({item}) => {
)
}
@
connect
()
class
SearchResult
extends
PureComponent
{
prevScrollY
=
0
searchHead
=
React
.
createRef
()
swipeUp
=
'up'
swipeDown
=
'down'
state
=
{
courseList
:
[],
value
:
decodeURIComponent
(
getParam
(
'word'
))
||
''
,
searchHistory
:
JSON
.
parse
(
localStorage
.
getItem
(
'searchHistory'
))
||
[],
fixedHeader
:
false
,
searchHeadStyle
:
{},
swipeDirection
:
'up'
searchHeadStyle
:
{
top
:
0
},
swipeDirection
:
this
.
swipeUp
}
componentDidMount
()
{
...
...
@@ -80,42 +79,50 @@ class SearchResult extends PureComponent {
let
y
=
window
.
scrollY
,
headY
=
this
.
searchHead
.
current
.
offsetTop
if
(
y
<
this
.
prevScrollY
)
{
this
.
state
.
swipeDirection
!==
'down'
&&
this
.
setState
({
swipeDirection
:
'down'
},
()
=>
{
if
(
this
.
state
.
swipeDirection
===
'down'
){
this
.
setState
({
searchHeadStyle
:
{
top
:
`
${
y
>
headY
?
y
-
44
:
y
}
px`
}
})
}
})
if
(
this
.
state
.
swipeDirection
===
this
.
swipeDown
)
{
y
<=
headY
&&
this
.
state
.
searchHeadStyle
.
position
!==
'fixed'
&&
this
.
setState
({
searchHeadStyle
:
{
top
:
`0`
,
position
:
'fixed'
}
})
}
else
{
this
.
setState
({
swipeDirection
:
this
.
swipeDown
},
()
=>
{
if
(
this
.
state
.
swipeDirection
===
this
.
swipeDown
)
{
this
.
setState
({
searchHeadStyle
:
{
top
:
`
${
y
>
headY
?
y
-
44
:
y
}
px`
}
})
}
})
}
}
else
{
this
.
state
.
swipeDirection
!==
this
.
swipeUp
&&
this
.
setState
({
swipeDirection
:
'up'
swipeDirection
:
this
.
swipeUp
,
searchHeadStyle
:
{
position
:
'absolute'
,
top
:
`
${
y
}
px`
}
})
}
/*if (this.state.fixedHeader) {
y >= this.prevScrollY && this.setState({fixedHeader: false})
} else {
y <= this.prevScrollY && this.setState({fixedHeader: true})
}
this.searchHeadStyle = {
position: 'absolute',
top: `${y - 44}px`
}*/
}
this
.
prevScrollY
=
y
},
3
0
)
},
0
)
render
()
{
const
{
courseList
}
=
this
.
state
return
(
<
div
className
=
{
classnames
(
'search-result'
,
{
/*[this.state.fixedHeader ? 'fixed-header' : 'static-header']*/
})
}
>
className
=
{
'search-result'
}
>
<
ForwardRefSearchHead
handleSearch
=
{
this
.
handleSearch
}
value
=
{
this
.
state
.
value
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment