File tree Expand file tree Collapse file tree 7 files changed +70
-17
lines changed Expand file tree Collapse file tree 7 files changed +70
-17
lines changed Original file line number Diff line number Diff line change @@ -44,14 +44,6 @@ class Epub extends Component {
44
44
}
45
45
} ) ;
46
46
47
- this . book . ready . then ( ( ) => {
48
- if ( this . props . onReady ) this . props . onReady ( this . book ) ;
49
- } ) ;
50
-
51
- this . book . loaded . metadata . then ( ( nav ) => {
52
- if ( this . props . onMetadataReady ) this . props . onMetadataReady ( nav . toc ) ;
53
- } ) ;
54
-
55
47
this . book . loaded . navigation . then ( ( nav ) => {
56
48
if ( this . props . onNavigationReady ) this . props . onNavigationReady ( nav . toc ) ;
57
49
} ) ;
@@ -68,8 +60,15 @@ class Epub extends Component {
68
60
}
69
61
} ;
70
62
71
- this . rendition . on ( 'keyup' , this . keyListener ) ;
72
- document . addEventListener ( 'keyup' , this . keyListener , false ) ;
63
+ this . book . ready . then ( ( ) => {
64
+ if ( this . props . onReady ) this . props . onReady ( this . book ) ;
65
+ this . rendition . on ( 'keyup' , this . keyListener ) ;
66
+ document . addEventListener ( 'keyup' , this . keyListener , false ) ;
67
+ } ) ;
68
+
69
+ this . book . loaded . navigation . then ( ( nav ) => {
70
+ if ( this . props . onNavigationReady ) this . props . onNavigationReady ( nav . toc ) ;
71
+ } ) ;
73
72
}
74
73
75
74
componentWillUnmount ( ) {
Original file line number Diff line number Diff line change
1
+ .loader__container {
2
+ position : absolute ;
3
+ top : 50% ;
4
+ left : 50% ;
5
+ right : 50% ;
6
+ bottom : 50% ;
7
+ display : flex ;
8
+ justify-content : center ;
9
+ align-items : center ;
10
+ font-size : 20px ;
11
+ text-align : center ;
12
+ flex-direction : column ;
13
+
14
+ > div {
15
+ padding : 20px 0 ;
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import Spinner from 'react-spinkit' ;
3
+ import './Loader.scss' ;
4
+
5
+ const Loader = ( ) => (
6
+ < div className = "loader__container" >
7
+ Loading
8
+ < Spinner
9
+ spinnerName = "chasing-dots"
10
+ noFadeIn
11
+ />
12
+ </ div >
13
+ ) ;
14
+
15
+ export default Loader ;
Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react' ;
2
2
import { Link } from 'react-router' ;
3
+ import Loader from '../Loader' ;
3
4
import Epub from '../Epub' ;
4
5
import getStreamHost from '../../utils/get-stream-host' ;
5
6
import './Reader.scss' ;
6
7
7
8
class Reader extends Component {
8
9
constructor ( props ) {
9
10
super ( props ) ;
10
- this . state = {
11
- "nav" : [ ] ,
12
- "location" : 0
13
- } ;
11
+ this . handleReady = this . handleReady . bind ( this ) ;
14
12
}
15
13
16
14
_navigationReady ( nav ) {
17
- this . setState ( { nav } ) ;
15
+ this . setState ( { ... this . state , nav } ) ;
18
16
}
19
17
20
18
_onNavClick ( item ) {
21
- this . setState ( { location : item . href } )
19
+ this . setState ( { ... this . state , location : item . href } ) ;
22
20
}
23
21
24
22
tocToggle ( ) {
@@ -29,6 +27,17 @@ class Reader extends Component {
29
27
} else {
30
28
navMenu . classList . add ( 'is-visible' ) ;
31
29
}
30
+
31
+ }
32
+
33
+ state = {
34
+ isLoading : true ,
35
+ nav : [ ] ,
36
+ location : 0
37
+ } ;
38
+
39
+ handleReady ( ) {
40
+ this . setState ( { ...this . state , isLoading : false } ) ;
32
41
}
33
42
34
43
render ( ) {
@@ -76,6 +85,7 @@ class Reader extends Component {
76
85
</ a >
77
86
</ div >
78
87
</ nav >
88
+ { this . state . isLoading && < Loader /> }
79
89
< Epub
80
90
src = { `${ getStreamHost ( ) } /${ book . id } /${ download } /` }
81
91
onNavigationReady = { this . _navigationReady . bind ( this ) }
Original file line number Diff line number Diff line change 147
147
"react" : " ^15.4.2" ,
148
148
"react-dom" : " ^15.4.2" ,
149
149
"react-router" : " ^3.0.2" ,
150
+ "react-spinkit" : " ^2.0.0" ,
150
151
"sass-loader" : " ^5.0.1" ,
151
152
"source-map-support" : " ^0.4.10"
152
153
},
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ import { dependencies as externals } from './app/package.json';
9
9
export default validate ( {
10
10
module : {
11
11
loaders : [ {
12
+ test : / \. c s s $ / ,
13
+ loader : 'style!css'
14
+ } ,
15
+ {
12
16
test : / \. j s x ? $ / ,
13
17
loaders : [ 'babel-loader' ] ,
14
18
exclude : / n o d e _ m o d u l e s /
Original file line number Diff line number Diff line change @@ -1616,7 +1616,7 @@ clap@^1.0.9:
1616
1616
dependencies :
1617
1617
chalk "^1.1.3"
1618
1618
1619
- classnames@^2.2.5 :
1619
+ classnames@^2.2.3, classnames@^2.2. 5 :
1620
1620
version "2.2.5"
1621
1621
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.5.tgz#fb3801d453467649ef3603c7d61a02bd129bde6d"
1622
1622
@@ -5250,6 +5250,13 @@ react-router@^3.0.2:
5250
5250
loose-envify "^1.2.0"
5251
5251
warning "^3.0.0"
5252
5252
5253
+ react-spinkit@^2.0.0 :
5254
+ version "2.0.0"
5255
+ resolved "https://registry.yarnpkg.com/react-spinkit/-/react-spinkit-2.0.0.tgz#1b010bc69f54bc2bdfa7587fcbab44c249bebdbe"
5256
+ dependencies :
5257
+ classnames "^2.2.3"
5258
+ object-assign "^4.1.0"
5259
+
5253
5260
react-transform-catch-errors@^1.0.2 :
5254
5261
version "1.0.2"
5255
5262
resolved "https://registry.yarnpkg.com/react-transform-catch-errors/-/react-transform-catch-errors-1.0.2.tgz#1b4d4a76e97271896fc16fe3086c793ec88a9eeb"
You can’t perform that action at this time.
0 commit comments