33import React from "react" ;
44import initialState from "./initial-state" ;
55import { debounce } from "throttle-debounce" ;
6- import classnames from "classnames " ;
6+ import { clsx } from "clsx " ;
77import {
88 getOnDemandLazySlides ,
99 extractObject ,
@@ -25,7 +25,6 @@ import {
2525import { Track } from "./track" ;
2626import { Dots } from "./dots" ;
2727import { PrevArrow , NextArrow } from "./arrows" ;
28- import ResizeObserver from "resize-observer-polyfill" ;
2928
3029export class InnerSlider extends React . Component {
3130 constructor ( props ) {
@@ -78,17 +77,19 @@ export class InnerSlider extends React.Component {
7877 if ( this . props . lazyLoad === "progressive" ) {
7978 this . lazyLoadTimer = setInterval ( this . progressiveLazyLoad , 1000 ) ;
8079 }
81- this . ro = new ResizeObserver ( ( ) => {
82- if ( this . state . animating ) {
83- this . onWindowResized ( false ) ; // don't set trackStyle hence don't break animation
84- this . callbackTimers . push (
85- setTimeout ( ( ) => this . onWindowResized ( ) , this . props . speed )
86- ) ;
87- } else {
88- this . onWindowResized ( ) ;
89- }
90- } ) ;
91- this . ro . observe ( this . list ) ;
80+ if ( typeof ResizeObserver !== "undefined" ) {
81+ this . ro = new ResizeObserver ( ( ) => {
82+ if ( this . state . animating ) {
83+ this . onWindowResized ( false ) ; // don't set trackStyle hence don't break animation
84+ this . callbackTimers . push (
85+ setTimeout ( ( ) => this . onWindowResized ( ) , this . props . speed )
86+ ) ;
87+ } else {
88+ this . onWindowResized ( ) ;
89+ }
90+ } ) ;
91+ this . ro . observe ( this . list ) ;
92+ }
9293 document . querySelectorAll &&
9394 Array . prototype . forEach . call (
9495 document . querySelectorAll ( ".slick-slide" ) ,
@@ -122,7 +123,7 @@ export class InnerSlider extends React.Component {
122123 if ( this . autoplayTimer ) {
123124 clearInterval ( this . autoplayTimer ) ;
124125 }
125- this . ro . disconnect ( ) ;
126+ this . ro ? .disconnect ( ) ;
126127 } ;
127128
128129 didPropsChange ( prevProps ) {
@@ -619,7 +620,7 @@ export class InnerSlider extends React.Component {
619620 this . autoPlay ( "blur" ) ;
620621
621622 render = ( ) => {
622- var className = classnames ( "slick-slider" , this . props . className , {
623+ var className = clsx ( "slick-slider" , this . props . className , {
623624 "slick-vertical" : this . props . vertical ,
624625 "slick-initialized" : true
625626 } ) ;
0 commit comments