Js ООП Class Slick slider
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
class SlickSlider { constructor(id, countShow, countScroll, idArrows, idDots) { this.elem = id; this.slidesToShow = countShow; this.slidesToScroll = countScroll; this.appendArrows = $(idArrows); this.appendDots = $(idDots); this.responsives = []; } get initSlider() { return this.init(); } init() { let options = this.slider(); if (this.responsives) { options.responsive = this.responsives; } $(this.elem).slick(options); } slider() { return { slidesToShow: this.slidesToShow, slidesToScroll: this.slidesToScroll, dots: true, appendArrows: this.appendArrows, appendDots: this.appendDots, touchThreshold: 10 } } addResponsive(weight, mobileShow, mobileScroll) { let obj = { breakpoint: weight, settings: { slidesToShow: mobileShow, slidesToScroll: mobileScroll } }; this.responsives.push(obj); } } let slider = new SlickSlider('.slider-item-four', 4, 1, '.slider-control-four', '.slider-control-four .slider-dots'); slider.addResponsive(1680,3,1); slider.addResponsive(1580, 2, 1); slider.initSlider; |