Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
R
react-pull-to-refresh
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jason.yap
react-pull-to-refresh
Commits
224b0118
Commit
224b0118
authored
Dec 21, 2017
by
李勇諭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve pull region
parent
f21d1ea7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
15 deletions
+9
-15
examples/Basic.tsx
examples/Basic.tsx
+1
-1
src/PullToRefresh.tsx
src/PullToRefresh.tsx
+8
-14
No files found.
examples/Basic.tsx
View file @
224b0118
...
@@ -25,7 +25,7 @@ export class Basic extends React.Component<BasicProps, BasicState> {
...
@@ -25,7 +25,7 @@ export class Basic extends React.Component<BasicProps, BasicState> {
onRefresh=
{
this
.
onRefresh
}
onRefresh=
{
this
.
onRefresh
}
>
>
<
div
style=
{
{
height
:
"
95vh
"
,
textAlign
:
"
center
"
}
}
>
<
div
style=
{
{
height
:
"
95vh
"
,
textAlign
:
"
center
"
}
}
>
PullToRefresh
<
div
onClick=
{
console
.
log
}
>
PullToRefresh
</
div
>
</
div
>
</
div
>
</
PullToRefresh
>
</
PullToRefresh
>
</
div
>
</
div
>
...
...
src/PullToRefresh.tsx
View file @
224b0118
...
@@ -51,29 +51,32 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
...
@@ -51,29 +51,32 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
}
}
public
componentDidMount
():
void
{
public
componentDidMount
():
void
{
this
.
pullTag
.
addEventListener
(
"
touchstart
"
,
this
.
onTouchStart
);
this
.
container
.
addEventListener
(
"
touchstart
"
,
this
.
onTouchStart
);
this
.
container
.
addEventListener
(
"
touchmove
"
,
this
.
onTouchMove
);
this
.
container
.
addEventListener
(
"
touchmove
"
,
this
.
onTouchMove
);
this
.
container
.
addEventListener
(
"
touchend
"
,
this
.
onEnd
);
this
.
container
.
addEventListener
(
"
touchend
"
,
this
.
onEnd
);
this
.
pullTag
.
addEventListener
(
"
mousedown
"
,
this
.
onTouchStart
);
this
.
container
.
addEventListener
(
"
mousedown
"
,
this
.
onTouchStart
);
this
.
container
.
addEventListener
(
"
mousemove
"
,
this
.
onTouchMove
);
this
.
container
.
addEventListener
(
"
mousemove
"
,
this
.
onTouchMove
);
this
.
container
.
addEventListener
(
"
mouseup
"
,
this
.
onEnd
);
this
.
container
.
addEventListener
(
"
mouseup
"
,
this
.
onEnd
);
}
}
public
componentWillUnmount
():
void
{
public
componentWillUnmount
():
void
{
this
.
pullTag
.
removeEventListener
(
"
touchstart
"
,
this
.
onTouchStart
);
this
.
container
.
removeEventListener
(
"
touchstart
"
,
this
.
onTouchStart
);
this
.
container
.
removeEventListener
(
"
touchmove
"
,
this
.
onTouchMove
);
this
.
container
.
removeEventListener
(
"
touchmove
"
,
this
.
onTouchMove
);
this
.
container
.
removeEventListener
(
"
touchend
"
,
this
.
onEnd
);
this
.
container
.
removeEventListener
(
"
touchend
"
,
this
.
onEnd
);
this
.
pullTag
.
removeEventListener
(
"
mousedown
"
,
this
.
onTouchStart
);
this
.
container
.
removeEventListener
(
"
mousedown
"
,
this
.
onTouchStart
);
this
.
container
.
removeEventListener
(
"
mousemove
"
,
this
.
onTouchMove
);
this
.
container
.
removeEventListener
(
"
mousemove
"
,
this
.
onTouchMove
);
this
.
container
.
removeEventListener
(
"
mouseup
"
,
this
.
onEnd
);
this
.
container
.
removeEventListener
(
"
mouseup
"
,
this
.
onEnd
);
}
}
@
autobind
@
autobind
private
onTouchStart
(
e
)
{
private
onTouchStart
(
e
)
{
this
.
dragging
=
true
;
this
.
startY
=
e
[
"
pageY
"
]
||
e
.
touches
[
0
].
pageY
;
this
.
startY
=
e
[
"
pageY
"
]
||
e
.
touches
[
0
].
pageY
;
this
.
currentY
=
this
.
startY
;
this
.
currentY
=
this
.
startY
;
if
(
this
.
startY
>
40
)
{
return
;
}
this
.
dragging
=
true
;
this
.
container
.
style
.
transition
=
"
transform 0.2s cubic-bezier(0,0,0.31,1)
"
;
this
.
container
.
style
.
transition
=
"
transform 0.2s cubic-bezier(0,0,0.31,1)
"
;
this
.
pullDown
.
style
.
transition
=
"
transform 0.2s cubic-bezier(0,0,0.31,1)
"
;
this
.
pullDown
.
style
.
transition
=
"
transform 0.2s cubic-bezier(0,0,0.31,1)
"
;
}
}
...
@@ -166,19 +169,10 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
...
@@ -166,19 +169,10 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
backgroundColor
:
"
white
"
,
backgroundColor
:
"
white
"
,
};
};
const
pullHiddenTagStyle
:
React
.
CSSProperties
=
{
height
:
"
50px
"
,
width
:
"
100%
"
,
position
:
"
absolute
"
,
top
:
0
,
zIndex
:
100
,
};
return
(
return
(
<
div
style=
{
containerStyle
}
>
<
div
style=
{
containerStyle
}
>
{
this
.
renderPullDownContent
()
}
{
this
.
renderPullDownContent
()
}
<
div
ref=
{
this
.
containerRef
}
style=
{
containerStyle
}
>
<
div
ref=
{
this
.
containerRef
}
style=
{
containerStyle
}
>
<
div
ref=
{
this
.
pullTagRef
}
style=
{
pullHiddenTagStyle
}
/>
{
this
.
props
.
children
}
{
this
.
props
.
children
}
</
div
>
</
div
>
</
div
>
</
div
>
...
...
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