Skip to content

Commit 83e3222

Browse files
committed
delay the pull-to-refresh spinner
1 parent b6dc426 commit 83e3222

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

source/views/menus/menu-bonapp.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {AllHtmlEntities} from 'html-entities'
2727
import {toLaxTitleCase} from 'titlecase'
2828
import {tracker} from '../../analytics'
2929
import bugsnag from '../../bugsnag'
30+
import delay from 'delay'
3031
const CENTRAL_TZ = 'America/Winnipeg'
3132

3233
const bonappMenuBaseUrl = 'http://legacy.cafebonappetit.com/api/2/menus'
@@ -102,10 +103,17 @@ export class BonAppHostedMenu extends React.Component<void, Props, State> {
102103
}
103104

104105
refresh = async () => {
106+
const start = Date.now()
105107
this.setState(() => ({refreshing: true}))
106108

107109
await this.fetchData(this.props)
108110

111+
// wait 0.5 seconds – if we let it go at normal speed, it feels broken.
112+
const elapsed = Date.now() - start
113+
if (elapsed < 500) {
114+
await delay(500 - elapsed)
115+
}
116+
109117
this.setState(() => ({refreshing: false}))
110118
}
111119

0 commit comments

Comments
 (0)