inner-slider.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import { createVNode as _createVNode } from "vue";
  3. var __rest = this && this.__rest || function (s, e) {
  4. var t = {};
  5. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  6. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  7. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  8. }
  9. return t;
  10. };
  11. import debounce from 'lodash-es/debounce';
  12. import ResizeObserver from 'resize-observer-polyfill';
  13. import classnames from '../_util/classNames';
  14. import BaseMixin from '../_util/BaseMixin';
  15. import defaultProps from './default-props';
  16. import initialState from './initial-state';
  17. import { getOnDemandLazySlides, extractObject, initializedState, getHeight, canGoNext, slideHandler, changeSlide, keyHandler, swipeStart, swipeMove, swipeEnd, getPreClones, getPostClones, getTrackLeft, getTrackCSS } from './utils/innerSliderUtils';
  18. import Track from './track';
  19. import Dots from './dots';
  20. import { PrevArrow, NextArrow } from './arrows';
  21. import supportsPassive from '../_util/supportsPassive';
  22. function noop() {}
  23. export default {
  24. name: 'InnerSlider',
  25. mixins: [BaseMixin],
  26. inheritAttrs: false,
  27. props: _extends({}, defaultProps),
  28. data() {
  29. this.preProps = _extends({}, this.$props);
  30. this.list = null;
  31. this.track = null;
  32. this.callbackTimers = [];
  33. this.clickable = true;
  34. this.debouncedResize = null;
  35. const ssrState = this.ssrInit();
  36. return _extends(_extends(_extends({}, initialState), {
  37. currentSlide: this.initialSlide,
  38. slideCount: this.children.length
  39. }), ssrState);
  40. },
  41. watch: {
  42. autoplay(newValue, oldValue) {
  43. if (!oldValue && newValue) {
  44. this.handleAutoPlay('playing');
  45. } else if (newValue) {
  46. this.handleAutoPlay('update');
  47. } else {
  48. this.pause('paused');
  49. }
  50. },
  51. __propsSymbol__() {
  52. const nextProps = this.$props;
  53. const spec = _extends(_extends({
  54. listRef: this.list,
  55. trackRef: this.track
  56. }, nextProps), this.$data);
  57. let setTrackStyle = false;
  58. for (const key of Object.keys(this.preProps)) {
  59. if (!nextProps.hasOwnProperty(key)) {
  60. setTrackStyle = true;
  61. break;
  62. }
  63. if (typeof nextProps[key] === 'object' || typeof nextProps[key] === 'function' || typeof nextProps[key] === 'symbol') {
  64. continue;
  65. }
  66. if (nextProps[key] !== this.preProps[key]) {
  67. setTrackStyle = true;
  68. break;
  69. }
  70. }
  71. this.updateState(spec, setTrackStyle, () => {
  72. if (this.currentSlide >= nextProps.children.length) {
  73. this.changeSlide({
  74. message: 'index',
  75. index: nextProps.children.length - nextProps.slidesToShow,
  76. currentSlide: this.currentSlide
  77. });
  78. }
  79. if (!this.preProps.autoplay && nextProps.autoplay) {
  80. this.handleAutoPlay('playing');
  81. } else if (nextProps.autoplay) {
  82. this.handleAutoPlay('update');
  83. } else {
  84. this.pause('paused');
  85. }
  86. });
  87. this.preProps = _extends({}, nextProps);
  88. }
  89. },
  90. mounted() {
  91. this.__emit('init');
  92. if (this.lazyLoad) {
  93. const slidesToLoad = getOnDemandLazySlides(_extends(_extends({}, this.$props), this.$data));
  94. if (slidesToLoad.length > 0) {
  95. this.setState(prevState => ({
  96. lazyLoadedList: prevState.lazyLoadedList.concat(slidesToLoad)
  97. }));
  98. this.__emit('lazyLoad', slidesToLoad);
  99. }
  100. }
  101. this.$nextTick(() => {
  102. const spec = _extends({
  103. listRef: this.list,
  104. trackRef: this.track,
  105. children: this.children
  106. }, this.$props);
  107. this.updateState(spec, true, () => {
  108. this.adaptHeight();
  109. this.autoplay && this.handleAutoPlay('playing');
  110. });
  111. if (this.lazyLoad === 'progressive') {
  112. this.lazyLoadTimer = setInterval(this.progressiveLazyLoad, 1000);
  113. }
  114. this.ro = new ResizeObserver(() => {
  115. if (this.animating) {
  116. this.onWindowResized(false); // don't set trackStyle hence don't break animation
  117. this.callbackTimers.push(setTimeout(() => this.onWindowResized(), this.speed));
  118. } else {
  119. this.onWindowResized();
  120. }
  121. });
  122. this.ro.observe(this.list);
  123. document.querySelectorAll && Array.prototype.forEach.call(document.querySelectorAll('.slick-slide'), slide => {
  124. slide.onfocus = this.$props.pauseOnFocus ? this.onSlideFocus : null;
  125. slide.onblur = this.$props.pauseOnFocus ? this.onSlideBlur : null;
  126. });
  127. if (window.addEventListener) {
  128. window.addEventListener('resize', this.onWindowResized);
  129. } else {
  130. window.attachEvent('onresize', this.onWindowResized);
  131. }
  132. });
  133. },
  134. beforeUnmount() {
  135. var _a;
  136. if (this.animationEndCallback) {
  137. clearTimeout(this.animationEndCallback);
  138. }
  139. if (this.lazyLoadTimer) {
  140. clearInterval(this.lazyLoadTimer);
  141. }
  142. if (this.callbackTimers.length) {
  143. this.callbackTimers.forEach(timer => clearTimeout(timer));
  144. this.callbackTimers = [];
  145. }
  146. if (window.addEventListener) {
  147. window.removeEventListener('resize', this.onWindowResized);
  148. } else {
  149. window.detachEvent('onresize', this.onWindowResized);
  150. }
  151. if (this.autoplayTimer) {
  152. clearInterval(this.autoplayTimer);
  153. }
  154. (_a = this.ro) === null || _a === void 0 ? void 0 : _a.disconnect();
  155. },
  156. updated() {
  157. this.checkImagesLoad();
  158. this.__emit('reInit');
  159. if (this.lazyLoad) {
  160. const slidesToLoad = getOnDemandLazySlides(_extends(_extends({}, this.$props), this.$data));
  161. if (slidesToLoad.length > 0) {
  162. this.setState(prevState => ({
  163. lazyLoadedList: prevState.lazyLoadedList.concat(slidesToLoad)
  164. }));
  165. this.__emit('lazyLoad');
  166. }
  167. }
  168. // if (this.props.onLazyLoad) {
  169. // this.props.onLazyLoad([leftMostSlide])
  170. // }
  171. this.adaptHeight();
  172. },
  173. methods: {
  174. listRefHandler(ref) {
  175. this.list = ref;
  176. },
  177. trackRefHandler(ref) {
  178. this.track = ref;
  179. },
  180. adaptHeight() {
  181. if (this.adaptiveHeight && this.list) {
  182. const elem = this.list.querySelector(`[data-index="${this.currentSlide}"]`);
  183. this.list.style.height = getHeight(elem) + 'px';
  184. }
  185. },
  186. onWindowResized(setTrackStyle) {
  187. if (this.debouncedResize) this.debouncedResize.cancel();
  188. this.debouncedResize = debounce(() => this.resizeWindow(setTrackStyle), 50);
  189. this.debouncedResize();
  190. },
  191. resizeWindow() {
  192. let setTrackStyle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  193. const isTrackMounted = Boolean(this.track);
  194. if (!isTrackMounted) return;
  195. const spec = _extends(_extends({
  196. listRef: this.list,
  197. trackRef: this.track,
  198. children: this.children
  199. }, this.$props), this.$data);
  200. this.updateState(spec, setTrackStyle, () => {
  201. if (this.autoplay) {
  202. this.handleAutoPlay('update');
  203. } else {
  204. this.pause('paused');
  205. }
  206. });
  207. // animating state should be cleared while resizing, otherwise autoplay stops working
  208. this.setState({
  209. animating: false
  210. });
  211. clearTimeout(this.animationEndCallback);
  212. delete this.animationEndCallback;
  213. },
  214. updateState(spec, setTrackStyle, callback) {
  215. const updatedState = initializedState(spec);
  216. spec = _extends(_extends(_extends({}, spec), updatedState), {
  217. slideIndex: updatedState.currentSlide
  218. });
  219. const targetLeft = getTrackLeft(spec);
  220. spec = _extends(_extends({}, spec), {
  221. left: targetLeft
  222. });
  223. const trackStyle = getTrackCSS(spec);
  224. if (setTrackStyle || this.children.length !== spec.children.length) {
  225. updatedState['trackStyle'] = trackStyle;
  226. }
  227. this.setState(updatedState, callback);
  228. },
  229. ssrInit() {
  230. const children = this.children;
  231. if (this.variableWidth) {
  232. let trackWidth = 0;
  233. let trackLeft = 0;
  234. const childrenWidths = [];
  235. const preClones = getPreClones(_extends(_extends(_extends({}, this.$props), this.$data), {
  236. slideCount: children.length
  237. }));
  238. const postClones = getPostClones(_extends(_extends(_extends({}, this.$props), this.$data), {
  239. slideCount: children.length
  240. }));
  241. children.forEach(child => {
  242. var _a, _b;
  243. const childWidth = ((_b = (_a = child.props.style) === null || _a === void 0 ? void 0 : _a.width) === null || _b === void 0 ? void 0 : _b.split('px')[0]) || 0;
  244. childrenWidths.push(childWidth);
  245. trackWidth += childWidth;
  246. });
  247. for (let i = 0; i < preClones; i++) {
  248. trackLeft += childrenWidths[childrenWidths.length - 1 - i];
  249. trackWidth += childrenWidths[childrenWidths.length - 1 - i];
  250. }
  251. for (let i = 0; i < postClones; i++) {
  252. trackWidth += childrenWidths[i];
  253. }
  254. for (let i = 0; i < this.currentSlide; i++) {
  255. trackLeft += childrenWidths[i];
  256. }
  257. const trackStyle = {
  258. width: trackWidth + 'px',
  259. left: -trackLeft + 'px'
  260. };
  261. if (this.centerMode) {
  262. const currentWidth = `${childrenWidths[this.currentSlide]}px`;
  263. trackStyle.left = `calc(${trackStyle.left} + (100% - ${currentWidth}) / 2 ) `;
  264. }
  265. return {
  266. trackStyle
  267. };
  268. }
  269. const childrenCount = children.length;
  270. const spec = _extends(_extends(_extends({}, this.$props), this.$data), {
  271. slideCount: childrenCount
  272. });
  273. const slideCount = getPreClones(spec) + getPostClones(spec) + childrenCount;
  274. const trackWidth = 100 / this.slidesToShow * slideCount;
  275. const slideWidth = 100 / slideCount;
  276. let trackLeft = -slideWidth * (getPreClones(spec) + this.currentSlide) * trackWidth / 100;
  277. if (this.centerMode) {
  278. trackLeft += (100 - slideWidth * trackWidth / 100) / 2;
  279. }
  280. const trackStyle = {
  281. width: trackWidth + '%',
  282. left: trackLeft + '%'
  283. };
  284. return {
  285. slideWidth: slideWidth + '%',
  286. trackStyle
  287. };
  288. },
  289. checkImagesLoad() {
  290. const images = this.list && this.list.querySelectorAll && this.list.querySelectorAll('.slick-slide img') || [];
  291. const imagesCount = images.length;
  292. let loadedCount = 0;
  293. Array.prototype.forEach.call(images, image => {
  294. const handler = () => ++loadedCount && loadedCount >= imagesCount && this.onWindowResized();
  295. if (!image.onclick) {
  296. image.onclick = () => image.parentNode.focus();
  297. } else {
  298. const prevClickHandler = image.onclick;
  299. image.onclick = () => {
  300. prevClickHandler();
  301. image.parentNode.focus();
  302. };
  303. }
  304. if (!image.onload) {
  305. if (this.$props.lazyLoad) {
  306. image.onload = () => {
  307. this.adaptHeight();
  308. this.callbackTimers.push(setTimeout(this.onWindowResized, this.speed));
  309. };
  310. } else {
  311. image.onload = handler;
  312. image.onerror = () => {
  313. handler();
  314. this.__emit('lazyLoadError');
  315. };
  316. }
  317. }
  318. });
  319. },
  320. progressiveLazyLoad() {
  321. const slidesToLoad = [];
  322. const spec = _extends(_extends({}, this.$props), this.$data);
  323. for (let index = this.currentSlide; index < this.slideCount + getPostClones(spec); index++) {
  324. if (this.lazyLoadedList.indexOf(index) < 0) {
  325. slidesToLoad.push(index);
  326. break;
  327. }
  328. }
  329. for (let index = this.currentSlide - 1; index >= -getPreClones(spec); index--) {
  330. if (this.lazyLoadedList.indexOf(index) < 0) {
  331. slidesToLoad.push(index);
  332. break;
  333. }
  334. }
  335. if (slidesToLoad.length > 0) {
  336. this.setState(state => ({
  337. lazyLoadedList: state.lazyLoadedList.concat(slidesToLoad)
  338. }));
  339. this.__emit('lazyLoad', slidesToLoad);
  340. } else {
  341. if (this.lazyLoadTimer) {
  342. clearInterval(this.lazyLoadTimer);
  343. delete this.lazyLoadTimer;
  344. }
  345. }
  346. },
  347. slideHandler(index) {
  348. let dontAnimate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  349. const {
  350. asNavFor,
  351. beforeChange,
  352. speed,
  353. afterChange
  354. } = this.$props;
  355. const {
  356. state,
  357. nextState
  358. } = slideHandler(_extends(_extends(_extends({
  359. index
  360. }, this.$props), this.$data), {
  361. trackRef: this.track,
  362. useCSS: this.useCSS && !dontAnimate
  363. }));
  364. if (!state) return;
  365. beforeChange && beforeChange(this.currentSlide, state.currentSlide);
  366. const slidesToLoad = state.lazyLoadedList.filter(value => this.lazyLoadedList.indexOf(value) < 0);
  367. if (this.$attrs.onLazyLoad && slidesToLoad.length > 0) {
  368. this.__emit('lazyLoad', slidesToLoad);
  369. }
  370. if (!this.$props.waitForAnimate && this.animationEndCallback) {
  371. clearTimeout(this.animationEndCallback);
  372. afterChange && afterChange(this.currentSlide);
  373. delete this.animationEndCallback;
  374. }
  375. this.setState(state, () => {
  376. if (asNavFor && this.asNavForIndex !== index) {
  377. this.asNavForIndex = index;
  378. asNavFor.innerSlider.slideHandler(index);
  379. }
  380. if (!nextState) return;
  381. this.animationEndCallback = setTimeout(() => {
  382. const {
  383. animating
  384. } = nextState,
  385. firstBatch = __rest(nextState, ["animating"]);
  386. this.setState(firstBatch, () => {
  387. this.callbackTimers.push(setTimeout(() => this.setState({
  388. animating
  389. }), 10));
  390. afterChange && afterChange(state.currentSlide);
  391. delete this.animationEndCallback;
  392. });
  393. }, speed);
  394. });
  395. },
  396. changeSlide(options) {
  397. let dontAnimate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  398. const spec = _extends(_extends({}, this.$props), this.$data);
  399. const targetSlide = changeSlide(spec, options);
  400. if (targetSlide !== 0 && !targetSlide) return;
  401. if (dontAnimate === true) {
  402. this.slideHandler(targetSlide, dontAnimate);
  403. } else {
  404. this.slideHandler(targetSlide);
  405. }
  406. this.$props.autoplay && this.handleAutoPlay('update');
  407. if (this.$props.focusOnSelect) {
  408. const nodes = this.list.querySelectorAll('.slick-current');
  409. nodes[0] && nodes[0].focus();
  410. }
  411. },
  412. clickHandler(e) {
  413. if (this.clickable === false) {
  414. e.stopPropagation();
  415. e.preventDefault();
  416. }
  417. this.clickable = true;
  418. },
  419. keyHandler(e) {
  420. const dir = keyHandler(e, this.accessibility, this.rtl);
  421. dir !== '' && this.changeSlide({
  422. message: dir
  423. });
  424. },
  425. selectHandler(options) {
  426. this.changeSlide(options);
  427. },
  428. disableBodyScroll() {
  429. const preventDefault = e => {
  430. e = e || window.event;
  431. if (e.preventDefault) e.preventDefault();
  432. e.returnValue = false;
  433. };
  434. window.ontouchmove = preventDefault;
  435. },
  436. enableBodyScroll() {
  437. window.ontouchmove = null;
  438. },
  439. swipeStart(e) {
  440. if (this.verticalSwiping) {
  441. this.disableBodyScroll();
  442. }
  443. const state = swipeStart(e, this.swipe, this.draggable);
  444. state !== '' && this.setState(state);
  445. },
  446. swipeMove(e) {
  447. const state = swipeMove(e, _extends(_extends(_extends({}, this.$props), this.$data), {
  448. trackRef: this.track,
  449. listRef: this.list,
  450. slideIndex: this.currentSlide
  451. }));
  452. if (!state) return;
  453. if (state['swiping']) {
  454. this.clickable = false;
  455. }
  456. this.setState(state);
  457. },
  458. swipeEnd(e) {
  459. const state = swipeEnd(e, _extends(_extends(_extends({}, this.$props), this.$data), {
  460. trackRef: this.track,
  461. listRef: this.list,
  462. slideIndex: this.currentSlide
  463. }));
  464. if (!state) return;
  465. const triggerSlideHandler = state['triggerSlideHandler'];
  466. delete state['triggerSlideHandler'];
  467. this.setState(state);
  468. if (triggerSlideHandler === undefined) return;
  469. this.slideHandler(triggerSlideHandler);
  470. if (this.$props.verticalSwiping) {
  471. this.enableBodyScroll();
  472. }
  473. },
  474. touchEnd(e) {
  475. this.swipeEnd(e);
  476. this.clickable = true;
  477. },
  478. slickPrev() {
  479. // this and fellow methods are wrapped in setTimeout
  480. // to make sure initialize setState has happened before
  481. // any of such methods are called
  482. this.callbackTimers.push(setTimeout(() => this.changeSlide({
  483. message: 'previous'
  484. }), 0));
  485. },
  486. slickNext() {
  487. this.callbackTimers.push(setTimeout(() => this.changeSlide({
  488. message: 'next'
  489. }), 0));
  490. },
  491. slickGoTo(slide) {
  492. let dontAnimate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  493. slide = Number(slide);
  494. if (isNaN(slide)) return '';
  495. this.callbackTimers.push(setTimeout(() => this.changeSlide({
  496. message: 'index',
  497. index: slide,
  498. currentSlide: this.currentSlide
  499. }, dontAnimate), 0));
  500. },
  501. play() {
  502. let nextIndex;
  503. if (this.rtl) {
  504. nextIndex = this.currentSlide - this.slidesToScroll;
  505. } else {
  506. if (canGoNext(_extends(_extends({}, this.$props), this.$data))) {
  507. nextIndex = this.currentSlide + this.slidesToScroll;
  508. } else {
  509. return false;
  510. }
  511. }
  512. this.slideHandler(nextIndex);
  513. },
  514. handleAutoPlay(playType) {
  515. if (this.autoplayTimer) {
  516. clearInterval(this.autoplayTimer);
  517. }
  518. const autoplaying = this.autoplaying;
  519. if (playType === 'update') {
  520. if (autoplaying === 'hovered' || autoplaying === 'focused' || autoplaying === 'paused') {
  521. return;
  522. }
  523. } else if (playType === 'leave') {
  524. if (autoplaying === 'paused' || autoplaying === 'focused') {
  525. return;
  526. }
  527. } else if (playType === 'blur') {
  528. if (autoplaying === 'paused' || autoplaying === 'hovered') {
  529. return;
  530. }
  531. }
  532. this.autoplayTimer = setInterval(this.play, this.autoplaySpeed + 50);
  533. this.setState({
  534. autoplaying: 'playing'
  535. });
  536. },
  537. pause(pauseType) {
  538. if (this.autoplayTimer) {
  539. clearInterval(this.autoplayTimer);
  540. this.autoplayTimer = null;
  541. }
  542. const autoplaying = this.autoplaying;
  543. if (pauseType === 'paused') {
  544. this.setState({
  545. autoplaying: 'paused'
  546. });
  547. } else if (pauseType === 'focused') {
  548. if (autoplaying === 'hovered' || autoplaying === 'playing') {
  549. this.setState({
  550. autoplaying: 'focused'
  551. });
  552. }
  553. } else {
  554. // pauseType is 'hovered'
  555. if (autoplaying === 'playing') {
  556. this.setState({
  557. autoplaying: 'hovered'
  558. });
  559. }
  560. }
  561. },
  562. onDotsOver() {
  563. this.autoplay && this.pause('hovered');
  564. },
  565. onDotsLeave() {
  566. this.autoplay && this.autoplaying === 'hovered' && this.handleAutoPlay('leave');
  567. },
  568. onTrackOver() {
  569. this.autoplay && this.pause('hovered');
  570. },
  571. onTrackLeave() {
  572. this.autoplay && this.autoplaying === 'hovered' && this.handleAutoPlay('leave');
  573. },
  574. onSlideFocus() {
  575. this.autoplay && this.pause('focused');
  576. },
  577. onSlideBlur() {
  578. this.autoplay && this.autoplaying === 'focused' && this.handleAutoPlay('blur');
  579. },
  580. customPaging(_ref) {
  581. let {
  582. i
  583. } = _ref;
  584. return _createVNode("button", null, [i + 1]);
  585. },
  586. appendDots(_ref2) {
  587. let {
  588. dots
  589. } = _ref2;
  590. return _createVNode("ul", {
  591. "style": {
  592. display: 'block'
  593. }
  594. }, [dots]);
  595. }
  596. },
  597. render() {
  598. const className = classnames('slick-slider', this.$attrs.class, {
  599. 'slick-vertical': this.vertical,
  600. 'slick-initialized': true
  601. });
  602. const spec = _extends(_extends({}, this.$props), this.$data);
  603. let trackProps = extractObject(spec, ['fade', 'cssEase', 'speed', 'infinite', 'centerMode', 'focusOnSelect', 'currentSlide', 'lazyLoad', 'lazyLoadedList', 'rtl', 'slideWidth', 'slideHeight', 'listHeight', 'vertical', 'slidesToShow', 'slidesToScroll', 'slideCount', 'trackStyle', 'variableWidth', 'unslick', 'centerPadding', 'targetSlide', 'useCSS']);
  604. const {
  605. pauseOnHover
  606. } = this.$props;
  607. trackProps = _extends(_extends({}, trackProps), {
  608. focusOnSelect: this.focusOnSelect && this.clickable ? this.selectHandler : null,
  609. ref: this.trackRefHandler,
  610. onMouseleave: pauseOnHover ? this.onTrackLeave : noop,
  611. onMouseover: pauseOnHover ? this.onTrackOver : noop
  612. });
  613. let dots;
  614. if (this.dots === true && this.slideCount >= this.slidesToShow) {
  615. let dotProps = extractObject(spec, ['dotsClass', 'slideCount', 'slidesToShow', 'currentSlide', 'slidesToScroll', 'clickHandler', 'children', 'infinite', 'appendDots']);
  616. dotProps.customPaging = this.customPaging;
  617. dotProps.appendDots = this.appendDots;
  618. const {
  619. customPaging,
  620. appendDots
  621. } = this.$slots;
  622. if (customPaging) {
  623. dotProps.customPaging = customPaging;
  624. }
  625. if (appendDots) {
  626. dotProps.appendDots = appendDots;
  627. }
  628. const {
  629. pauseOnDotsHover
  630. } = this.$props;
  631. dotProps = _extends(_extends({}, dotProps), {
  632. clickHandler: this.changeSlide,
  633. onMouseover: pauseOnDotsHover ? this.onDotsOver : noop,
  634. onMouseleave: pauseOnDotsHover ? this.onDotsLeave : noop
  635. });
  636. dots = _createVNode(Dots, dotProps, null);
  637. }
  638. let prevArrow, nextArrow;
  639. const arrowProps = extractObject(spec, ['infinite', 'centerMode', 'currentSlide', 'slideCount', 'slidesToShow']);
  640. arrowProps.clickHandler = this.changeSlide;
  641. const {
  642. prevArrow: prevArrowCustom,
  643. nextArrow: nextArrowCustom
  644. } = this.$slots;
  645. if (prevArrowCustom) {
  646. arrowProps.prevArrow = prevArrowCustom;
  647. }
  648. if (nextArrowCustom) {
  649. arrowProps.nextArrow = nextArrowCustom;
  650. }
  651. if (this.arrows) {
  652. prevArrow = _createVNode(PrevArrow, arrowProps, null);
  653. nextArrow = _createVNode(NextArrow, arrowProps, null);
  654. }
  655. let verticalHeightStyle = null;
  656. if (this.vertical) {
  657. verticalHeightStyle = {
  658. height: typeof this.listHeight === 'number' ? `${this.listHeight}px` : this.listHeight
  659. };
  660. }
  661. let centerPaddingStyle = null;
  662. if (this.vertical === false) {
  663. if (this.centerMode === true) {
  664. centerPaddingStyle = {
  665. padding: '0px ' + this.centerPadding
  666. };
  667. }
  668. } else {
  669. if (this.centerMode === true) {
  670. centerPaddingStyle = {
  671. padding: this.centerPadding + ' 0px'
  672. };
  673. }
  674. }
  675. const listStyle = _extends(_extends({}, verticalHeightStyle), centerPaddingStyle);
  676. const touchMove = this.touchMove;
  677. let listProps = {
  678. ref: this.listRefHandler,
  679. class: 'slick-list',
  680. style: listStyle,
  681. onClick: this.clickHandler,
  682. onMousedown: touchMove ? this.swipeStart : noop,
  683. onMousemove: this.dragging && touchMove ? this.swipeMove : noop,
  684. onMouseup: touchMove ? this.swipeEnd : noop,
  685. onMouseleave: this.dragging && touchMove ? this.swipeEnd : noop,
  686. [supportsPassive ? 'onTouchstartPassive' : 'onTouchstart']: touchMove ? this.swipeStart : noop,
  687. [supportsPassive ? 'onTouchmovePassive' : 'onTouchmove']: this.dragging && touchMove ? this.swipeMove : noop,
  688. onTouchend: touchMove ? this.touchEnd : noop,
  689. onTouchcancel: this.dragging && touchMove ? this.swipeEnd : noop,
  690. onKeydown: this.accessibility ? this.keyHandler : noop
  691. };
  692. let innerSliderProps = {
  693. class: className,
  694. dir: 'ltr',
  695. style: this.$attrs.style
  696. };
  697. if (this.unslick) {
  698. listProps = {
  699. class: 'slick-list',
  700. ref: this.listRefHandler
  701. };
  702. innerSliderProps = {
  703. class: className
  704. };
  705. }
  706. return _createVNode("div", innerSliderProps, [!this.unslick ? prevArrow : '', _createVNode("div", listProps, [_createVNode(Track, trackProps, {
  707. default: () => [this.children]
  708. })]), !this.unslick ? nextArrow : '', !this.unslick ? dots : '']);
  709. }
  710. };