@@ -9,11 +9,22 @@ const canUseDOM = !!(
99 window . document . createElement
1010) ;
1111
12-
13- export type FlickityEventName = 'ready' | 'change' | 'select' | 'settle' | 'scroll' | 'dragStart'
14- | 'dragMove' | 'dragEnd' | 'pointerDown' | 'pointerMove' | 'pointerUp'
15- | 'staticClick' | 'lazyLoad' | 'bgLazyLoad' | 'fullscreenChange' ;
16-
12+ export type FlickityEventName =
13+ | 'ready'
14+ | 'change'
15+ | 'select'
16+ | 'settle'
17+ | 'scroll'
18+ | 'dragStart'
19+ | 'dragMove'
20+ | 'dragEnd'
21+ | 'pointerDown'
22+ | 'pointerMove'
23+ | 'pointerUp'
24+ | 'staticClick'
25+ | 'lazyLoad'
26+ | 'bgLazyLoad'
27+ | 'fullscreenChange' ;
1728
1829export interface ReactFlickityComponentProps {
1930 className ?: string ;
@@ -40,7 +51,10 @@ interface FlickityInstance extends Flickity {
4051 activate : ( ) => void ;
4152}
4253
43- class FlickityComponent extends Component < ReactFlickityComponentProps , FlickityComponentState > {
54+ class FlickityComponent extends Component <
55+ ReactFlickityComponentProps ,
56+ FlickityComponentState
57+ > {
4458 static defaultProps : Partial < ReactFlickityComponentProps > = {
4559 className : '' ,
4660 disableImagesLoaded : false ,
@@ -63,14 +77,20 @@ class FlickityComponent extends Component<ReactFlickityComponentProps, FlickityC
6377 } ;
6478 }
6579
66- static getDerivedStateFromProps ( props : ReactFlickityComponentProps , state : FlickityComponentState ) {
80+ static getDerivedStateFromProps (
81+ props : ReactFlickityComponentProps ,
82+ state : FlickityComponentState
83+ ) {
6784 const cellCount = React . Children . count ( props . children ) ;
6885 if ( cellCount !== state . cellCount )
6986 return { flickityReady : false , cellCount } ;
7087 return null ;
7188 }
7289
73- componentDidUpdate ( prevProps : ReactFlickityComponentProps , prevState : FlickityComponentState ) {
90+ componentDidUpdate (
91+ prevProps : ReactFlickityComponentProps ,
92+ prevState : FlickityComponentState
93+ ) {
7494 if ( ! this . flkty ) return ;
7595 const {
7696 children,
@@ -79,7 +99,7 @@ class FlickityComponent extends Component<ReactFlickityComponentProps, FlickityC
7999 disableImagesLoaded,
80100 } = this . props ;
81101 const { flickityReady } = this . state ;
82-
102+
83103 if ( reloadOnUpdate || ( ! prevState . flickityReady && flickityReady ) ) {
84104 const isActive = this . flkty . isActive ;
85105 this . flkty . deactivate ( ) ;
@@ -101,7 +121,6 @@ class FlickityComponent extends Component<ReactFlickityComponentProps, FlickityC
101121 }
102122 }
103123
104-
105124 async componentDidMount ( ) {
106125 if ( ! canUseDOM || ! this . carousel ) return ;
107126 const FlickityClass = ( await import ( 'flickity' ) ) . default ;
@@ -133,8 +152,13 @@ class FlickityComponent extends Component<ReactFlickityComponentProps, FlickityC
133152 }
134153
135154 render ( ) {
136- const { elementType = 'div' , className = '' , static : isStatic , children } = this . props ;
137-
155+ const {
156+ elementType = 'div' ,
157+ className = '' ,
158+ static : isStatic ,
159+ children,
160+ } = this . props ;
161+
138162 return React . createElement (
139163 elementType ,
140164 {
@@ -148,4 +172,4 @@ class FlickityComponent extends Component<ReactFlickityComponentProps, FlickityC
148172 }
149173}
150174
151- export default FlickityComponent ;
175+ export default FlickityComponent ;
0 commit comments