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
2977a1c6
Commit
2977a1c6
authored
Apr 15, 2019
by
Carlos
Committed by
GitHub
Apr 15, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into master
parents
45ff666d
2aca5550
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
1 deletion
+9
-1
README.md
README.md
+2
-0
__tests__/components/PullToRefresh.spec.tsx
__tests__/components/PullToRefresh.spec.tsx
+1
-0
__tests__/components/__snapshots__/PullToRefresh.spec.tsx.snap
...ts__/components/__snapshots__/PullToRefresh.spec.tsx.snap
+1
-0
src/components/PullToRefresh.tsx
src/components/PullToRefresh.tsx
+5
-1
No files found.
README.md
View file @
2977a1c6
...
@@ -31,6 +31,7 @@ or
...
@@ -31,6 +31,7 @@ or
|onRefresh|Promise|true|
|onRefresh|Promise|true|
|triggerHeight|number|false|
|triggerHeight|number|false|
|backgroundColor|string|false|
|backgroundColor|string|false|
|startInvisible|boolean|false|
## Usage
## Usage
...
@@ -55,6 +56,7 @@ import {PullDownContent, ReleaseContent, RefreshContent} from "react-js-pull-to-
...
@@ -55,6 +56,7 @@ import {PullDownContent, ReleaseContent, RefreshContent} from "react-js-pull-to-
onRefresh
=
{
this
.
onRefresh
}
onRefresh
=
{
this
.
onRefresh
}
triggerHeight
=
{
50
}
triggerHeight
=
{
50
}
backgroundColor
=
'
white
'
backgroundColor
=
'
white
'
startInvisible
=
{
true
}
>
>
<
div
style=
{
{
height
:
'
150vh
'
,
textAlign
:
'
center
'
}
}
>
<
div
style=
{
{
height
:
'
150vh
'
,
textAlign
:
'
center
'
}
}
>
<
div
>
PullToRefresh
</
div
>
<
div
>
PullToRefresh
</
div
>
...
...
__tests__/components/PullToRefresh.spec.tsx
View file @
2977a1c6
...
@@ -14,6 +14,7 @@ describe("PullToRefresh spec", () => {
...
@@ -14,6 +14,7 @@ describe("PullToRefresh spec", () => {
pullDownThreshold=
{
200
}
pullDownThreshold=
{
200
}
triggerHeight=
{
100
}
triggerHeight=
{
100
}
backgroundColor=
"white"
backgroundColor=
"white"
startInvisible=
{
false
}
>
>
<
div
>
Test
</
div
>
<
div
>
Test
</
div
>
</
PullToRefresh
>
</
PullToRefresh
>
...
...
__tests__/components/__snapshots__/PullToRefresh.spec.tsx.snap
View file @
2977a1c6
...
@@ -21,6 +21,7 @@ exports[`PullToRefresh spec App shows PullToRefresh 1`] = `
...
@@ -21,6 +21,7 @@ exports[`PullToRefresh spec App shows PullToRefresh 1`] = `
"position": "absolute",
"position": "absolute",
"right": 0,
"right": 0,
"top": 0,
"top": 0,
"visibility": "visible",
}
}
}
}
>
>
...
...
src/components/PullToRefresh.tsx
View file @
2977a1c6
...
@@ -9,6 +9,7 @@ export interface PullToRefreshProps {
...
@@ -9,6 +9,7 @@ export interface PullToRefreshProps {
onRefresh
:
()
=>
Promise
<
any
>
;
onRefresh
:
()
=>
Promise
<
any
>
;
triggerHeight
?:
number
|
"
auto
"
;
triggerHeight
?:
number
|
"
auto
"
;
backgroundColor
?:
string
;
backgroundColor
?:
string
;
startInvisible
?:
boolean
;
}
}
export
interface
PullToRefreshState
{
export
interface
PullToRefreshState
{
...
@@ -136,6 +137,7 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
...
@@ -136,6 +137,7 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
this
.
container
.
style
.
overflow
=
"
visible
"
;
this
.
container
.
style
.
overflow
=
"
visible
"
;
this
.
container
.
style
.
transform
=
`translate(0px,
${
this
.
currentY
-
this
.
startY
}
px)`
;
this
.
container
.
style
.
transform
=
`translate(0px,
${
this
.
currentY
-
this
.
startY
}
px)`
;
this
.
pullDown
.
style
.
visibility
=
"
visible
"
;
}
}
private
onEnd
()
{
private
onEnd
()
{
...
@@ -144,6 +146,7 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
...
@@ -144,6 +146,7 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
this
.
currentY
=
0
;
this
.
currentY
=
0
;
if
(
!
this
.
state
.
pullToRefreshThresholdBreached
)
{
if
(
!
this
.
state
.
pullToRefreshThresholdBreached
)
{
this
.
pullDown
.
style
.
visibility
=
this
.
props
.
startInvisible
?
"
hidden
"
:
"
visible
"
;
this
.
initContainer
();
this
.
initContainer
();
return
;
return
;
}
}
...
@@ -175,7 +178,7 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
...
@@ -175,7 +178,7 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
}
}
private
renderPullDownContent
()
{
private
renderPullDownContent
()
{
const
{
releaseContent
,
pullDownContent
,
refreshContent
}
=
this
.
props
;
const
{
releaseContent
,
pullDownContent
,
refreshContent
,
startInvisible
}
=
this
.
props
;
const
{
onRefreshing
,
pullToRefreshThresholdBreached
}
=
this
.
state
;
const
{
onRefreshing
,
pullToRefreshThresholdBreached
}
=
this
.
state
;
const
content
=
onRefreshing
?
refreshContent
:
pullToRefreshThresholdBreached
?
releaseContent
:
pullDownContent
;
const
content
=
onRefreshing
?
refreshContent
:
pullToRefreshThresholdBreached
?
releaseContent
:
pullDownContent
;
const
contentStyle
:
React
.
CSSProperties
=
{
const
contentStyle
:
React
.
CSSProperties
=
{
...
@@ -184,6 +187,7 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
...
@@ -184,6 +187,7 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
left
:
0
,
left
:
0
,
right
:
0
,
right
:
0
,
top
:
0
,
top
:
0
,
visibility
:
startInvisible
?
"
hidden
"
:
"
visible
"
,
};
};
return
(
return
(
<
div
style=
{
contentStyle
}
ref=
{
this
.
pullDownRef
}
>
<
div
style=
{
contentStyle
}
ref=
{
this
.
pullDownRef
}
>
...
...
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