File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
example/components/ParallaxTest Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 1- import React from 'react' ;
1+ import React , { Component } from 'react' ;
2+ import { PropTypes } from 'prop-types' ;
23import { Parallax } from 'react-scroll-parallax' ;
34import style from './ParallaxTest.scss' ;
45
56const INC_AMOUNT = 10 ;
67const START_NUM_ELEMENTS = 10 ;
78
8- export default class ParallaxTest extends React . Component {
9+ export default class ParallaxTest extends Component {
10+ static contextTypes = {
11+ parallaxController : PropTypes . object . isRequired ,
12+ } ;
13+
914 state = {
1015 elements : new Array ( START_NUM_ELEMENTS ) . fill ( null ) . map ( ( x , i ) => i ) ,
1116 offsetY : INC_AMOUNT ,
@@ -14,6 +19,10 @@ export default class ParallaxTest extends React.Component {
1419 disabled : false ,
1520 } ;
1621
22+ triggerDestroy = ( ) => {
23+ this . context . parallaxController . destroy ( ) ;
24+ } ;
25+
1726 handleAdd = ( ) => {
1827 const elements = [ ...this . state . elements , this . state . elements . length ] ;
1928 this . setState ( {
@@ -158,6 +167,14 @@ export default class ParallaxTest extends React.Component {
158167 { this . state . disabled ? 'Enable' : 'Disable' }
159168 </ button >
160169 </ div >
170+ < div className = { style . currentState } >
171+ < h4 >
172+ Destroys the ParallaxController. :-(
173+ </ h4 >
174+ < button onClick = { this . triggerDestroy } >
175+ Destroy
176+ </ button >
177+ </ div >
161178 </ div >
162179 </ div >
163180 ) ;
You can’t perform that action at this time.
0 commit comments