This repository was archived by the owner on Aug 7, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +27
-8
lines changed Expand file tree Collapse file tree 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].
6262
6363### ` style={ Object } `
6464
65- Style attribute to be passed to the generated < ; ul/> ; element [ optional] .
65+ Style attribute to be passed to the generated < ; ul/> ; element [ optional] .
6666
6767### ` offset={ Number } `
6868
@@ -72,6 +72,16 @@ Offset value that adjusts to determine the elements are in the viewport [optiona
7272
7373Name of the element of scrollable container that can be used with querySelector [ optional] .
7474
75+ ## Methods
76+
77+ ### ` offEvent `
78+
79+ Remove event listener of scrollspy.
80+
81+ ### ` onEvent `
82+
83+ Add event listener of scrollspy.
84+
7585
7686## Development
7787
Original file line number Diff line number Diff line change @@ -199,17 +199,25 @@ export default class Scrollspy extends React.Component {
199199 this . _spy ( targetItems )
200200 }
201201
202- componentDidMount ( ) {
203- this . _initFromProps ( )
202+ offEvent ( ) {
204203 const el = this . props . rootEl ? document . querySelector ( this . props . rootEl ) : window
205204
206- el . addEventListener ( 'scroll' , this . _handleSpy )
205+ el . removeEventListener ( 'scroll' , this . _handleSpy )
207206 }
208207
209- componentWillUnmount ( ) {
208+ onEvent ( ) {
210209 const el = this . props . rootEl ? document . querySelector ( this . props . rootEl ) : window
211210
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 ( )
213221 }
214222
215223 componentWillReceiveProps ( ) {
Original file line number Diff line number Diff line change 11import webpack from 'webpack'
22import path from 'path'
3- import HtmlWebpackPlguin from 'html-webpack-plugin' ;
3+ import HtmlWebpackPlguin from 'html-webpack-plugin'
44
55export default {
66 entry : {
@@ -14,7 +14,7 @@ export default {
1414 output : {
1515 path : path . join ( __dirname , 'dist' ) ,
1616 filename : 'js/[name].js' ,
17- publicPath : 'http://localhost:8080 ' ,
17+ publicPath : '/ ' ,
1818 } ,
1919 resolve : {
2020 modules : [
@@ -57,6 +57,7 @@ export default {
5757 } ,
5858 devServer : {
5959 contentBase : './dist' ,
60+ publicPath : '/' ,
6061 port : 8080 ,
6162 } ,
6263 plugins : [
You can’t perform that action at this time.
0 commit comments