This repository was archived by the owner on Aug 7, 2021. It is now read-only.
File tree 3 files changed +27
-8
lines changed
3 files changed +27
-8
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ HTML tag for Scrollspy component if you want to use other than `ul` [optional].
62
62
63
63
### ` style={ Object } `
64
64
65
- Style attribute to be passed to the generated < ; ul/> ; element [ optional] .
65
+ Style attribute to be passed to the generated < ; ul/> ; element [ optional] .
66
66
67
67
### ` offset={ Number } `
68
68
@@ -72,6 +72,16 @@ Offset value that adjusts to determine the elements are in the viewport [optiona
72
72
73
73
Name of the element of scrollable container that can be used with querySelector [ optional] .
74
74
75
+ ## Methods
76
+
77
+ ### ` offEvent `
78
+
79
+ Remove event listener of scrollspy.
80
+
81
+ ### ` onEvent `
82
+
83
+ Add event listener of scrollspy.
84
+
75
85
76
86
## Development
77
87
Original file line number Diff line number Diff line change @@ -199,17 +199,25 @@ export default class Scrollspy extends React.Component {
199
199
this . _spy ( targetItems )
200
200
}
201
201
202
- componentDidMount ( ) {
203
- this . _initFromProps ( )
202
+ offEvent ( ) {
204
203
const el = this . props . rootEl ? document . querySelector ( this . props . rootEl ) : window
205
204
206
- el . addEventListener ( 'scroll' , this . _handleSpy )
205
+ el . removeEventListener ( 'scroll' , this . _handleSpy )
207
206
}
208
207
209
- componentWillUnmount ( ) {
208
+ onEvent ( ) {
210
209
const el = this . props . rootEl ? document . querySelector ( this . props . rootEl ) : window
211
210
212
- el . removeEventListener ( 'scroll' , this . _handleSpy )
211
+ el . addEventListener ( 'scroll' , this . _handleSpy )
212
+ }
213
+
214
+ componentDidMount ( ) {
215
+ this . _initFromProps ( )
216
+ this . onEvent ( )
217
+ }
218
+
219
+ componentWillUnmount ( ) {
220
+ this . offEvent ( )
213
221
}
214
222
215
223
componentWillReceiveProps ( ) {
Original file line number Diff line number Diff line change 1
1
import webpack from 'webpack'
2
2
import path from 'path'
3
- import HtmlWebpackPlguin from 'html-webpack-plugin' ;
3
+ import HtmlWebpackPlguin from 'html-webpack-plugin'
4
4
5
5
export default {
6
6
entry : {
@@ -14,7 +14,7 @@ export default {
14
14
output : {
15
15
path : path . join ( __dirname , 'dist' ) ,
16
16
filename : 'js/[name].js' ,
17
- publicPath : 'http://localhost:8080 ' ,
17
+ publicPath : '/ ' ,
18
18
} ,
19
19
resolve : {
20
20
modules : [
@@ -57,6 +57,7 @@ export default {
57
57
} ,
58
58
devServer : {
59
59
contentBase : './dist' ,
60
+ publicPath : '/' ,
60
61
port : 8080 ,
61
62
} ,
62
63
plugins : [
You can’t perform that action at this time.
0 commit comments