hooper 0.2.2 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Hopper 0.2.1
2
+ * Hopper 0.3.2
3
3
  * (c) 2019
4
4
  * @license MIT
5
5
  */
@@ -39,6 +39,26 @@ function _objectSpread(target) {
39
39
  return target;
40
40
  }
41
41
 
42
+ function _toConsumableArray(arr) {
43
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
44
+ }
45
+
46
+ function _arrayWithoutHoles(arr) {
47
+ if (Array.isArray(arr)) {
48
+ for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
49
+
50
+ return arr2;
51
+ }
52
+ }
53
+
54
+ function _iterableToArray(iter) {
55
+ if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
56
+ }
57
+
58
+ function _nonIterableSpread() {
59
+ throw new TypeError("Invalid attempt to spread non-iterable instance");
60
+ }
61
+
42
62
  function getInRange(value, min, max) {
43
63
  return Math.max(Math.min(value, max), min);
44
64
  }
@@ -76,47 +96,81 @@ function camelCaseToString(camelCase) {
76
96
  return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
77
97
  }
78
98
  function normalizeSlideIndex(index, slidesCount) {
99
+ var realIndex;
100
+
79
101
  if (index < 0) {
80
- return (index + slidesCount) % slidesCount;
102
+ realIndex = (index + slidesCount) % slidesCount;
103
+ } else {
104
+ realIndex = index % slidesCount;
105
+ } // Test for NaN
106
+
107
+
108
+ if (realIndex !== realIndex) {
109
+ return 0;
81
110
  }
82
111
 
83
- return index % slidesCount;
112
+ return realIndex;
84
113
  }
114
+ function cloneNode(h, vNode) {
115
+ // use the context that the original vnode was created in.
116
+ var children = vNode.children || vNode.componentOptions.children || vNode.text;
117
+ var tag = vNode.componentOptions.Ctor;
118
+ return h(tag, vNode.data, children);
119
+ } // IE11 :)
120
+
121
+ function assignPoly(target) {
122
+ if (target === undefined || target === null) {
123
+ throw new TypeError('Cannot convert first argument to object');
124
+ }
85
125
 
86
- function extractData(vnode, indx) {
87
- var cOpts = vnode.componentOptions;
88
- var data = {
89
- class: vnode.data.class,
90
- staticClass: vnode.data.staticClass,
91
- style: vnode.data.style,
92
- attrs: vnode.data.attrs,
93
- props: _objectSpread({}, cOpts.propsData, {
94
- isClone: true,
95
- index: indx
96
- }),
97
- on: cOpts.listeners,
98
- nativeOn: vnode.data.nativeOn,
99
- directives: vnode.data.directives,
100
- scopesSlots: vnode.data.scopesSlots,
101
- slot: vnode.data.slot,
102
- ref: vnode.data.ref,
103
- key: vnode.data.key ? "".concat(indx, "-clone") : undefined
104
- };
105
- return data;
126
+ var to = Object(target);
127
+
128
+ for (var i = 1; i < arguments.length; i++) {
129
+ var nextSource = arguments[i];
130
+
131
+ if (nextSource === undefined || nextSource === null) {
132
+ continue;
133
+ }
134
+
135
+ nextSource = Object(nextSource);
136
+ var keysArray = Object.keys(Object(nextSource));
137
+
138
+ for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
139
+ var nextKey = keysArray[nextIndex];
140
+ var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
141
+
142
+ if (desc !== undefined && desc.enumerable) {
143
+ to[nextKey] = nextSource[nextKey];
144
+ }
145
+ }
146
+ }
147
+
148
+ return to;
106
149
  }
107
150
 
108
- function cloneSlide(vnode, indx) {
109
- // use the context that the original vnode was created in.
110
- var h = vnode.context && vnode.context.$createElement;
111
- var children = vnode.componentOptions.children;
112
- var data = extractData(vnode, indx);
113
- var tag = vnode.componentOptions.Ctor;
114
- return h(tag, data, children);
151
+ var assign = Object.assign || assignPoly;
152
+
153
+ function signPoly(value) {
154
+ if (value < 0) {
155
+ return -1;
156
+ }
157
+
158
+ return value > 0 ? 1 : 0;
159
+ }
160
+
161
+ var sign = Math.sign || signPoly;
162
+ function normalizeChildren(context) {
163
+ var slotProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
164
+
165
+ if (context.$scopedSlots.default) {
166
+ return context.$scopedSlots.default(slotProps) || [];
167
+ }
168
+
169
+ return context.$slots.default || [];
115
170
  }
116
171
 
117
- //
118
172
  var EMITTER = new Vue();
119
- var script = {
173
+ var Carousel = {
120
174
  name: 'Hooper',
121
175
  provide: function provide() {
122
176
  return {
@@ -235,7 +289,6 @@ var script = {
235
289
  trimEnd: 1,
236
290
  currentSlide: null,
237
291
  timer: null,
238
- slides: [],
239
292
  defaults: {},
240
293
  breakpoints: {},
241
294
  delta: {
@@ -338,11 +391,11 @@ var script = {
338
391
  }
339
392
 
340
393
  if (this.config.mouseDrag) {
341
- this.$refs.track.addEventListener('mousedown', this.onDragStart);
394
+ this.$refs.list.addEventListener('mousedown', this.onDragStart);
342
395
  }
343
396
 
344
397
  if (this.config.touchDrag) {
345
- this.$refs.track.addEventListener('touchstart', this.onDragStart, {
398
+ this.$refs.list.addEventListener('touchstart', this.onDragStart, {
346
399
  passive: true
347
400
  });
348
401
  }
@@ -379,28 +432,8 @@ var script = {
379
432
  },
380
433
  initDefaults: function initDefaults() {
381
434
  this.breakpoints = this.settings.breakpoints;
382
- this.defaults = Object.assign({}, this.$props, this.settings);
383
- this.config = Object.assign({}, this.defaults);
384
- },
385
- initSlides: function initSlides() {
386
- var _this3 = this;
387
-
388
- this.slides = this.filteredSlides();
389
- this.slidesCount = this.slides.length;
390
- this.slides.forEach(function (slide, indx) {
391
- slide.componentOptions.propsData.index = indx;
392
- });
393
-
394
- if (this.config.infiniteScroll) {
395
- var before = [];
396
- var after = [];
397
- this.slides.forEach(function (slide, indx) {
398
- before.push(cloneSlide(slide, indx - _this3.slidesCount));
399
- after.push(cloneSlide(slide, indx + _this3.slidesCount));
400
- });
401
- this.$slots['clone-before'] = before;
402
- this.$slots['clone-after'] = after;
403
- }
435
+ this.defaults = assign({}, this.$props, this.settings);
436
+ this.config = assign({}, this.defaults);
404
437
  },
405
438
  // updating methods
406
439
  update: function update() {
@@ -447,7 +480,7 @@ var script = {
447
480
  this.slideWidth = this.containerWidth / this.config.itemsToShow;
448
481
  },
449
482
  updateConfig: function updateConfig() {
450
- var _this4 = this;
483
+ var _this3 = this;
451
484
 
452
485
  var breakpoints = Object.keys(this.breakpoints).sort(function (a, b) {
453
486
  return b - a;
@@ -457,13 +490,13 @@ var script = {
457
490
  matched = window.matchMedia("(min-width: ".concat(breakpoint, "px)")).matches;
458
491
 
459
492
  if (matched) {
460
- _this4.config = Object.assign({}, _this4.config, _this4.defaults, _this4.breakpoints[breakpoint]);
493
+ _this3.config = assign({}, _this3.config, _this3.defaults, _this3.breakpoints[breakpoint]);
461
494
  return true;
462
495
  }
463
496
  });
464
497
 
465
498
  if (!matched) {
466
- this.config = Object.assign(this.config, this.defaults);
499
+ this.config = assign(this.config, this.defaults);
467
500
  }
468
501
  },
469
502
  restartTimer: function restartTimer() {
@@ -472,11 +505,10 @@ var script = {
472
505
  }
473
506
  },
474
507
  restart: function restart() {
475
- var _this5 = this;
508
+ var _this4 = this;
476
509
 
477
- this.initSlides();
478
510
  this.$nextTick(function () {
479
- _this5.update();
511
+ _this4.update();
480
512
  });
481
513
  },
482
514
  // events handlers
@@ -500,7 +532,10 @@ var script = {
500
532
  this.startPosition.y = this.isTouch ? event.touches[0].clientY : event.clientY;
501
533
  document.addEventListener(this.isTouch ? 'touchmove' : 'mousemove', this.onDrag);
502
534
  document.addEventListener(this.isTouch ? 'touchend' : 'mouseup', this.onDragEnd);
503
- event.preventDefault();
535
+
536
+ if (event.type !== 'touchstart') {
537
+ event.preventDefault();
538
+ }
504
539
  },
505
540
  onDrag: function onDrag(event) {
506
541
  if (this.isSliding) {
@@ -511,7 +546,10 @@ var script = {
511
546
  this.endPosition.y = this.isTouch ? event.touches[0].clientY : event.clientY;
512
547
  this.delta.x = this.endPosition.x - this.startPosition.x;
513
548
  this.delta.y = this.endPosition.y - this.startPosition.y;
514
- event.preventDefault();
549
+
550
+ if (!this.isTouch) {
551
+ event.preventDefault();
552
+ }
515
553
  },
516
554
  onDragEnd: function onDragEnd() {
517
555
  var tolerance = this.config.shortDrag ? 0.5 : 0.15;
@@ -519,11 +557,11 @@ var script = {
519
557
 
520
558
  if (this.config.vertical) {
521
559
  var draggedSlides = Math.round(Math.abs(this.delta.y / this.slideHeight) + tolerance);
522
- this.slideTo(this.currentSlide - Math.sign(this.delta.y) * draggedSlides);
560
+ this.slideTo(this.currentSlide - sign(this.delta.y) * draggedSlides);
523
561
  }
524
562
 
525
563
  if (!this.config.vertical) {
526
- var direction = (this.config.rtl ? -1 : 1) * Math.sign(this.delta.x);
564
+ var direction = (this.config.rtl ? -1 : 1) * sign(this.delta.x);
527
565
 
528
566
  var _draggedSlides = Math.round(Math.abs(this.delta.x / this.slideWidth) + tolerance);
529
567
 
@@ -591,7 +629,7 @@ var script = {
591
629
 
592
630
  this.lastScrollTime = now();
593
631
  var value = event.wheelDelta || -event.deltaY;
594
- var delta = Math.sign(value);
632
+ var delta = sign(value);
595
633
 
596
634
  if (delta === -1) {
597
635
  this.slideNext();
@@ -601,17 +639,8 @@ var script = {
601
639
  this.slidePrev();
602
640
  }
603
641
  },
604
- filteredSlides: function filteredSlides() {
605
- return this.$slots.default.filter(function (el) {
606
- if (!el.componentOptions || !el.componentOptions.Ctor) {
607
- return false;
608
- }
609
-
610
- return el.componentOptions.Ctor.options.name === 'HooperSlide';
611
- });
612
- },
613
642
  addGroupListeners: function addGroupListeners() {
614
- var _this6 = this;
643
+ var _this5 = this;
615
644
 
616
645
  if (!this.group) {
617
646
  return;
@@ -619,35 +648,26 @@ var script = {
619
648
 
620
649
  this._groupSlideHandler = function (slideIndex) {
621
650
  // set the isSource to false to prevent infinite emitting loop.
622
- _this6.slideTo(slideIndex, false);
651
+ _this5.slideTo(slideIndex, false);
623
652
  };
624
653
 
625
654
  EMITTER.$on("slideGroup:".concat(this.group), this._groupSlideHandler);
626
655
  }
627
656
  },
628
- beforeUpdate: function beforeUpdate() {
629
- var isForcUpdated = this.config.infiniteScroll && (!this.$slots['clone-before'] || !this.$slots['clone-after']);
630
- var isSlidesUpdated = this.filteredSlides().length !== this.slidesCount;
631
-
632
- if (isForcUpdated || isSlidesUpdated) {
633
- this.initSlides();
634
- }
635
- },
636
657
  created: function created() {
637
658
  this.initDefaults();
638
- this.initSlides();
639
659
  },
640
660
  mounted: function mounted() {
641
- var _this7 = this;
661
+ var _this6 = this;
642
662
 
643
663
  this.initEvents();
644
664
  this.addGroupListeners();
645
665
  this.$nextTick(function () {
646
- _this7.update();
666
+ _this6.update();
647
667
 
648
- _this7.slideTo(_this7.config.initialSlide);
668
+ _this6.slideTo(_this6.config.initialSlide || 0);
649
669
 
650
- _this7.$emit('loaded');
670
+ _this6.$emit('loaded');
651
671
  });
652
672
  },
653
673
  beforeDestroy: function beforeDestroy() {
@@ -660,189 +680,147 @@ var script = {
660
680
  if (this.timer) {
661
681
  this.timer.stop();
662
682
  }
683
+ },
684
+ render: function render(h) {
685
+ var _this7 = this;
686
+
687
+ var body = renderBody.call(this, h);
688
+ return h('section', {
689
+ class: {
690
+ hooper: true,
691
+ 'is-vertical': this.config.vertical,
692
+ 'is-rtl': this.config.rtl
693
+ },
694
+ attrs: {
695
+ tabindex: '0'
696
+ },
697
+ on: {
698
+ focusin: function focusin() {
699
+ return _this7.isFocus = true;
700
+ },
701
+ focusout: function focusout() {
702
+ return _this7.isFocus = false;
703
+ },
704
+ mouseover: function mouseover() {
705
+ return _this7.isHover = true;
706
+ },
707
+ mouseleave: function mouseleave() {
708
+ return _this7.isHover = false;
709
+ }
710
+ }
711
+ }, body);
663
712
  }
664
713
  };
665
-
666
- function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier
667
- /* server only */
668
- , shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
669
- if (typeof shadowMode !== 'boolean') {
670
- createInjectorSSR = createInjector;
671
- createInjector = shadowMode;
672
- shadowMode = false;
673
- } // Vue.extend constructor export interop.
674
-
675
-
676
- var options = typeof script === 'function' ? script.options : script; // render functions
677
-
678
- if (template && template.render) {
679
- options.render = template.render;
680
- options.staticRenderFns = template.staticRenderFns;
681
- options._compiled = true; // functional template
682
-
683
- if (isFunctionalTemplate) {
684
- options.functional = true;
685
- }
686
- } // scopedId
687
-
688
-
689
- if (scopeId) {
690
- options._scopeId = scopeId;
714
+ /**
715
+ * Renders additional slides for infinite slides mode.
716
+ * By cloning Slides VNodes before and after either edges.
717
+ */
718
+
719
+ function renderBufferSlides(h, slides) {
720
+ var before = [];
721
+ var after = []; // reduce prop access
722
+
723
+ var slidesCount = slides.length;
724
+
725
+ for (var i = 0; i < slidesCount; i++) {
726
+ var slide = slides[i];
727
+ var clonedBefore = cloneNode(h, slide);
728
+ clonedBefore.data.key = "index-".concat(i - slidesCount);
729
+ clonedBefore.key = clonedBefore.data.key;
730
+ clonedBefore.data.props = {
731
+ index: i - slidesCount,
732
+ isClone: true
733
+ };
734
+ before.push(clonedBefore);
735
+ var clonedAfter = cloneNode(h, slide);
736
+ clonedAfter.data.key = "index-".concat(i + slidesCount);
737
+ clonedAfter.key = clonedAfter.data.key;
738
+ clonedAfter.data.props = {
739
+ index: i + slidesCount,
740
+ isClone: true
741
+ };
742
+ after.push(clonedAfter);
691
743
  }
692
744
 
693
- var hook;
694
-
695
- if (moduleIdentifier) {
696
- // server build
697
- hook = function hook(context) {
698
- // 2.3 injection
699
- context = context || // cached call
700
- this.$vnode && this.$vnode.ssrContext || // stateful
701
- this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext; // functional
702
- // 2.2 with runInNewContext: true
745
+ return [].concat(before, _toConsumableArray(slides), after);
746
+ }
747
+ /**
748
+ * Produces the VNodes for the Slides.
749
+ * requires {this} to be bound to hooper.
750
+ * So use with .call or .bind
751
+ */
703
752
 
704
- if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
705
- context = __VUE_SSR_CONTEXT__;
706
- } // inject component styles
707
753
 
754
+ function renderSlides(h) {
755
+ var children = normalizeChildren(this);
756
+ var childrenCount = children.length;
757
+ var idx = 0;
758
+ var slides = [];
708
759
 
709
- if (style) {
710
- style.call(this, createInjectorSSR(context));
711
- } // register component module identifier for async chunk inference
760
+ for (var i = 0; i < childrenCount; i++) {
761
+ var child = children[i];
762
+ var ctor = child.componentOptions && child.componentOptions.Ctor;
712
763
 
764
+ if (!ctor || ctor.options.name !== 'HooperSlide') {
765
+ continue;
766
+ } // give slide an index behind the scenes
713
767
 
714
- if (context && context._registeredComponents) {
715
- context._registeredComponents.add(moduleIdentifier);
716
- }
717
- }; // used by ssr in case component is cached and beforeCreate
718
- // never gets called
719
768
 
769
+ child.componentOptions.propsData.index = idx;
770
+ child.data.key = idx;
771
+ child.key = idx;
772
+ child.data.props = _objectSpread({}, child.data.props || {}, {
773
+ isClone: false,
774
+ index: idx++
775
+ });
776
+ slides.push(child);
777
+ } // update hooper's information of the slide count.
720
778
 
721
- options._ssrRegister = hook;
722
- } else if (style) {
723
- hook = shadowMode ? function () {
724
- style.call(this, createInjectorShadow(this.$root.$options.shadowRoot));
725
- } : function (context) {
726
- style.call(this, createInjector(context));
727
- };
728
- }
729
779
 
730
- if (hook) {
731
- if (options.functional) {
732
- // register for functional component in vue file
733
- var originalRender = options.render;
780
+ this.slidesCount = slides.length;
734
781
 
735
- options.render = function renderWithStyleInjection(h, context) {
736
- hook.call(context);
737
- return originalRender(h, context);
738
- };
739
- } else {
740
- // inject component registration as beforeCreate hook
741
- var existing = options.beforeCreate;
742
- options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
743
- }
782
+ if (this.config.infiniteScroll) {
783
+ slides = renderBufferSlides(h, slides);
744
784
  }
745
785
 
746
- return script;
747
- }
748
-
749
- var normalizeComponent_1 = normalizeComponent;
750
-
751
- /* script */
752
- var __vue_script__ = script;
753
- /* template */
754
-
755
- var __vue_render__ = function __vue_render__() {
756
- var _vm = this;
757
-
758
- var _h = _vm.$createElement;
759
-
760
- var _c = _vm._self._c || _h;
761
-
762
- return _c('section', {
763
- staticClass: "hooper",
764
- class: {
765
- 'is-vertical': _vm.config.vertical,
766
- 'is-rtl': _vm.config.rtl
767
- },
768
- attrs: {
769
- "tabindex": "0"
770
- },
771
- on: {
772
- "mouseover": function mouseover($event) {
773
- _vm.isHover = true;
774
- },
775
- "mouseleave": function mouseleave($event) {
776
- _vm.isHover = false;
777
- },
778
- "focusin": function focusin($event) {
779
- _vm.isFocus = true;
780
- },
781
- "focusout": function focusout($event) {
782
- _vm.isFocus = false;
783
- }
784
- }
785
- }, [_c('div', {
786
- staticClass: "hooper-list"
787
- }, [_c('ul', {
788
- ref: "track",
789
- staticClass: "hooper-track",
786
+ return h('ul', {
790
787
  class: {
791
- 'is-dragging': _vm.isDragging
788
+ 'hooper-track': true,
789
+ 'is-dragging': this.isDragging
792
790
  },
793
- style: _vm.trackTransform + _vm.trackTransition,
791
+ style: this.trackTransform + this.trackTransition,
792
+ ref: 'track',
794
793
  on: {
795
- "transitionend": _vm.onTransitionend
794
+ transitionend: this.onTransitionend
796
795
  }
797
- }, [_vm._t("clone-before"), _vm._v(" "), _vm._t("default"), _vm._v(" "), _vm._t("clone-after")], 2)]), _vm._v(" "), _vm._t("hooper-addons"), _vm._v(" "), _c('div', {
798
- staticClass: "hooper-liveregion hooper-sr-only",
796
+ }, slides);
797
+ }
798
+ /**
799
+ * Builds the VNodes for the hooper body.
800
+ * Which is the slides, addons if available, and a11y stuff.
801
+ * REQUIRES {this} to be bound to the hooper instance.
802
+ * use with .call or .bind
803
+ */
804
+
805
+
806
+ function renderBody(h) {
807
+ var slides = renderSlides.call(this, h);
808
+ var addons = this.$slots['hooper-addons'] || [];
809
+ var a11y = h('div', {
810
+ class: 'hooper-liveregion hooper-sr-only',
799
811
  attrs: {
800
- "aria-live": "polite",
801
- "aria-atomic": "true"
812
+ 'aria-live': 'polite',
813
+ 'aria-atomic': 'true'
802
814
  }
803
- }, [_vm._v("\n " + _vm._s("Item " + (_vm.currentSlide + 1) + " of " + _vm.slidesCount) + "\n ")])], 2);
804
- };
815
+ }, "Item ".concat(this.currentSlide + 1, " of ").concat(this.slidesCount));
816
+ var children = [slides].concat(_toConsumableArray(addons), [a11y]);
817
+ return [h('div', {
818
+ class: 'hooper-list',
819
+ ref: 'list'
820
+ }, children)];
821
+ }
805
822
 
806
- var __vue_staticRenderFns__ = [];
807
- /* style */
808
-
809
- var __vue_inject_styles__ = undefined;
810
- /* scoped */
811
-
812
- var __vue_scope_id__ = undefined;
813
- /* module identifier */
814
-
815
- var __vue_module_identifier__ = undefined;
816
- /* functional template */
817
-
818
- var __vue_is_functional_template__ = false;
819
- /* style inject */
820
-
821
- /* style inject SSR */
822
-
823
- var Hooper = normalizeComponent_1({
824
- render: __vue_render__,
825
- staticRenderFns: __vue_staticRenderFns__
826
- }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);
827
-
828
- //
829
- //
830
- //
831
- //
832
- //
833
- //
834
- //
835
- //
836
- //
837
- //
838
- //
839
- //
840
- //
841
- //
842
- //
843
- //
844
- //
845
- var script$1 = {
823
+ var Slide = {
846
824
  name: 'HooperSlide',
847
825
  inject: ['$hooper'],
848
826
  props: {
@@ -897,58 +875,27 @@ var script$1 = {
897
875
  isCurrent: function isCurrent() {
898
876
  return this.index === this.$hooper.currentSlide;
899
877
  }
878
+ },
879
+ render: function render(h) {
880
+ var classes = {
881
+ 'hooper-slide': true,
882
+ 'is-clone': this.isClone,
883
+ 'is-active': this.isActive,
884
+ 'is-prev': this.isPrev,
885
+ 'is-next': this.isNext,
886
+ 'is-current': this.isCurrent
887
+ };
888
+ var children = normalizeChildren(this);
889
+ return h('li', {
890
+ class: classes,
891
+ style: this.style,
892
+ attrs: {
893
+ 'aria-hidden': !this.isActive
894
+ }
895
+ }, children);
900
896
  }
901
897
  };
902
898
 
903
- /* script */
904
- var __vue_script__$1 = script$1;
905
- /* template */
906
-
907
- var __vue_render__$1 = function __vue_render__() {
908
- var _vm = this;
909
-
910
- var _h = _vm.$createElement;
911
-
912
- var _c = _vm._self._c || _h;
913
-
914
- return _c('li', {
915
- staticClass: "hooper-slide",
916
- class: {
917
- 'is-clone': _vm.isClone,
918
- 'is-active': _vm.isActive,
919
- 'is-prev': _vm.isPrev,
920
- 'is-next': _vm.isNext,
921
- 'is-current': _vm.isCurrent
922
- },
923
- style: _vm.style,
924
- attrs: {
925
- "aria-hidden": _vm.isActive
926
- }
927
- }, [_vm._t("default")], 2);
928
- };
929
-
930
- var __vue_staticRenderFns__$1 = [];
931
- /* style */
932
-
933
- var __vue_inject_styles__$1 = undefined;
934
- /* scoped */
935
-
936
- var __vue_scope_id__$1 = undefined;
937
- /* module identifier */
938
-
939
- var __vue_module_identifier__$1 = undefined;
940
- /* functional template */
941
-
942
- var __vue_is_functional_template__$1 = false;
943
- /* style inject */
944
-
945
- /* style inject SSR */
946
-
947
- var Slide = normalizeComponent_1({
948
- render: __vue_render__$1,
949
- staticRenderFns: __vue_staticRenderFns__$1
950
- }, __vue_inject_styles__$1, __vue_script__$1, __vue_scope_id__$1, __vue_is_functional_template__$1, __vue_module_identifier__$1, undefined, undefined);
951
-
952
899
  var Mixin = {
953
900
  inject: ['$hooper']
954
901
  };
@@ -959,7 +906,7 @@ var icons = {
959
906
  arrowRight: 'M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z',
960
907
  arrowLeft: 'M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z'
961
908
  };
962
- var Icons = {
909
+ var Icon = {
963
910
  name: 'HooperIcon',
964
911
  functional: true,
965
912
  inheritAttrs: true,
@@ -999,8 +946,7 @@ var Icons = {
999
946
  }
1000
947
  };
1001
948
 
1002
- //
1003
- var script$2 = {
949
+ var Progress = {
1004
950
  inject: ['$hooper'],
1005
951
  name: 'HooperProgress',
1006
952
  computed: {
@@ -1011,52 +957,54 @@ var script$2 = {
1011
957
  var range = this.$hooper.slidesCount - this.$hooper.trimStart - this.$hooper.trimEnd;
1012
958
  return (this.currentSlide - this.$hooper.trimStart) * 100 / range;
1013
959
  }
960
+ },
961
+ render: function render(h) {
962
+ return h('div', {
963
+ class: 'hooper-progress'
964
+ }, [h('div', {
965
+ class: 'hooper-progress-inner',
966
+ style: "width: ".concat(this.progress, "%")
967
+ })]);
1014
968
  }
1015
969
  };
1016
970
 
1017
- /* script */
1018
- var __vue_script__$2 = script$2;
1019
- /* template */
1020
-
1021
- var __vue_render__$2 = function __vue_render__() {
1022
- var _vm = this;
1023
-
1024
- var _h = _vm.$createElement;
1025
-
1026
- var _c = _vm._self._c || _h;
1027
-
1028
- return _c('div', {
1029
- staticClass: "hooper-progress"
1030
- }, [_c('div', {
1031
- staticClass: "hooper-progress-inner",
1032
- style: "width: " + _vm.progress + "%"
1033
- })]);
1034
- };
1035
-
1036
- var __vue_staticRenderFns__$2 = [];
1037
- /* style */
1038
-
1039
- var __vue_inject_styles__$2 = undefined;
1040
- /* scoped */
971
+ function renderFraction(h, current, totalCount) {
972
+ return [h('span', current + 1), h('span', '/'), h('span', totalCount)];
973
+ }
1041
974
 
1042
- var __vue_scope_id__$2 = undefined;
1043
- /* module identifier */
975
+ function renderIndicator(h, index, isCurrent, onClick) {
976
+ return h('li', [h('button', {
977
+ class: {
978
+ 'hooper-indicator': true,
979
+ 'is-active': isCurrent
980
+ },
981
+ on: {
982
+ click: onClick
983
+ }
984
+ }, [h('span', {
985
+ class: 'hooper-sr-only'
986
+ }, "item ".concat(index))])]);
987
+ }
1044
988
 
1045
- var __vue_module_identifier__$2 = undefined;
1046
- /* functional template */
989
+ function renderDefault(h, current, totalCount, slideToIndex) {
990
+ var children = [];
1047
991
 
1048
- var __vue_is_functional_template__$2 = false;
1049
- /* style inject */
992
+ var _loop = function _loop(i) {
993
+ children.push(renderIndicator(h, i, i === current, function () {
994
+ return slideToIndex(i);
995
+ }));
996
+ };
1050
997
 
1051
- /* style inject SSR */
998
+ for (var i = 0; i < totalCount; i++) {
999
+ _loop(i);
1000
+ }
1052
1001
 
1053
- var Progress = normalizeComponent_1({
1054
- render: __vue_render__$2,
1055
- staticRenderFns: __vue_staticRenderFns__$2
1056
- }, __vue_inject_styles__$2, __vue_script__$2, __vue_scope_id__$2, __vue_is_functional_template__$2, __vue_module_identifier__$2, undefined, undefined);
1002
+ return [h('ol', {
1003
+ class: 'hooper-indicators'
1004
+ }, children)];
1005
+ }
1057
1006
 
1058
- //
1059
- var script$3 = {
1007
+ var Pagination = {
1060
1008
  inject: ['$hooper'],
1061
1009
  name: 'HooperPagination',
1062
1010
  props: {
@@ -1075,75 +1023,55 @@ var script$3 = {
1075
1023
  });
1076
1024
  return slides.slice(this.$hooper.trimStart, this.$hooper.slidesCount - this.$hooper.trimEnd + 1);
1077
1025
  }
1078
- }
1079
- };
1080
-
1081
- /* script */
1082
- var __vue_script__$3 = script$3;
1083
- /* template */
1084
-
1085
- var __vue_render__$3 = function __vue_render__() {
1086
- var _vm = this;
1087
-
1088
- var _h = _vm.$createElement;
1089
-
1090
- var _c = _vm._self._c || _h;
1091
-
1092
- return _c('div', {
1093
- staticClass: "hooper-pagination",
1094
- class: {
1095
- 'is-vertical': _vm.$hooper.config.vertical
1096
- }
1097
- }, [_vm.mode === 'indicator' ? _c('ol', {
1098
- staticClass: "hooper-indicators"
1099
- }, _vm._l(_vm.slides, function (index) {
1100
- return _c('li', {
1101
- key: index
1102
- }, [_c('button', {
1103
- staticClass: "hooper-indicator",
1026
+ },
1027
+ render: function render(h) {
1028
+ var _this = this;
1029
+
1030
+ var totalCount = this.$hooper.slidesCount;
1031
+ var children = this.mode === 'indicator' ? renderDefault(h, this.currentSlide, totalCount, function (index) {
1032
+ return _this.$hooper.slideTo(index);
1033
+ }) : renderFraction(h, this.currentSlide, totalCount);
1034
+ return h('div', {
1104
1035
  class: {
1105
- 'is-active': _vm.currentSlide === index
1106
- },
1107
- on: {
1108
- "click": function click($event) {
1109
- return _vm.$hooper.slideTo(index);
1110
- }
1036
+ 'hooper-pagination': true,
1037
+ 'is-vertical': this.$hooper.config.vertical
1111
1038
  }
1112
- }, [_c('span', {
1113
- staticClass: "hooper-sr-only"
1114
- }, [_vm._v("item " + _vm._s(index))])])]);
1115
- }), 0) : _vm._e(), _vm._v(" "), _vm.mode === 'fraction' ? [_c('span', [_vm._v(_vm._s(_vm.currentSlide + 1))]), _vm._v(" "), _c('span', [_vm._v("/")]), _vm._v(" "), _c('span', [_vm._v(_vm._s(_vm.$hooper.slidesCount))])] : _vm._e()], 2);
1039
+ }, children);
1040
+ }
1116
1041
  };
1117
1042
 
1118
- var __vue_staticRenderFns__$3 = [];
1119
- /* style */
1120
-
1121
- var __vue_inject_styles__$3 = undefined;
1122
- /* scoped */
1123
-
1124
- var __vue_scope_id__$3 = undefined;
1125
- /* module identifier */
1126
-
1127
- var __vue_module_identifier__$3 = undefined;
1128
- /* functional template */
1043
+ function iconName(isVertical, isRTL, isPrev) {
1044
+ if (isPrev) {
1045
+ return isVertical ? 'arrowUp' : isRTL ? 'arrowRight' : 'arrowLeft';
1046
+ }
1129
1047
 
1130
- var __vue_is_functional_template__$3 = false;
1131
- /* style inject */
1048
+ return isVertical ? 'arrowDown' : isRTL ? 'arrowLeft' : 'arrowRight';
1049
+ }
1132
1050
 
1133
- /* style inject SSR */
1051
+ function renderButton(h, disabled, slot, isPrev, _ref, onClick) {
1052
+ var _class;
1134
1053
 
1135
- var Pagination = normalizeComponent_1({
1136
- render: __vue_render__$3,
1137
- staticRenderFns: __vue_staticRenderFns__$3
1138
- }, __vue_inject_styles__$3, __vue_script__$3, __vue_scope_id__$3, __vue_is_functional_template__$3, __vue_module_identifier__$3, undefined, undefined);
1054
+ var isVertical = _ref.isVertical,
1055
+ isRTL = _ref.isRTL;
1056
+ var children = slot && slot.length ? slot : [h(Icon, {
1057
+ props: {
1058
+ name: iconName(isVertical, isRTL, isPrev)
1059
+ }
1060
+ })];
1061
+ return h('button', {
1062
+ class: (_class = {}, _defineProperty(_class, "hooper-".concat(isPrev ? 'prev' : 'next'), true), _defineProperty(_class, 'is-disabled', disabled), _class),
1063
+ attrs: {
1064
+ type: 'button'
1065
+ },
1066
+ on: {
1067
+ click: onClick
1068
+ }
1069
+ }, children);
1070
+ }
1139
1071
 
1140
- //
1141
- var script$4 = {
1072
+ var Navigation = {
1142
1073
  inject: ['$hooper'],
1143
1074
  name: 'HooperNavigation',
1144
- components: {
1145
- Icons: Icons
1146
- },
1147
1075
  computed: {
1148
1076
  isPrevDisabled: function isPrevDisabled() {
1149
1077
  if (this.$hooper.config.infiniteScroll) {
@@ -1157,13 +1085,11 @@ var script$4 = {
1157
1085
  return false;
1158
1086
  }
1159
1087
 
1088
+ if (this.$hooper.config.trimWhiteSpace) {
1089
+ return this.$hooper.currentSlide === this.$hooper.slidesCount - Math.min(this.$hooper.config.itemsToShow, this.$hooper.slidesCount);
1090
+ }
1091
+
1160
1092
  return this.$hooper.currentSlide === this.$hooper.slidesCount - 1;
1161
- },
1162
- isRTL: function isRTL() {
1163
- return this.$hooper.config.rtl;
1164
- },
1165
- isVertical: function isVertical() {
1166
- return this.$hooper.config.vertical;
1167
1093
  }
1168
1094
  },
1169
1095
  methods: {
@@ -1175,80 +1101,28 @@ var script$4 = {
1175
1101
  this.$hooper.slidePrev();
1176
1102
  this.$hooper.restartTimer();
1177
1103
  }
1178
- }
1179
- };
1180
-
1181
- /* script */
1182
- var __vue_script__$4 = script$4;
1183
- /* template */
1184
-
1185
- var __vue_render__$4 = function __vue_render__() {
1186
- var _vm = this;
1187
-
1188
- var _h = _vm.$createElement;
1189
-
1190
- var _c = _vm._self._c || _h;
1104
+ },
1105
+ render: function render(h) {
1106
+ var _this = this;
1191
1107
 
1192
- return _c('div', {
1193
- staticClass: "hooper-navigation",
1194
- class: {
1195
- 'is-vertical': _vm.$hooper.config.vertical,
1196
- 'is-rtl': _vm.$hooper.config.rtl
1197
- }
1198
- }, [_c('button', {
1199
- staticClass: "hooper-prev",
1200
- class: {
1201
- 'is-disabled': _vm.isPrevDisabled
1202
- },
1203
- attrs: {
1204
- "type": "button"
1205
- },
1206
- on: {
1207
- "click": _vm.slidePrev
1208
- }
1209
- }, [_vm._t("hooper-prev", [_c('Icons', {
1210
- attrs: {
1211
- "name": _vm.isVertical ? 'arrowUp' : _vm.isRTL ? 'arrowRight' : 'arrowLeft'
1212
- }
1213
- })])], 2), _vm._v(" "), _c('button', {
1214
- staticClass: "hooper-next",
1215
- class: {
1216
- 'is-disabled': _vm.isNextDisabled
1217
- },
1218
- attrs: {
1219
- "type": "button"
1220
- },
1221
- on: {
1222
- "click": _vm.slideNext
1223
- }
1224
- }, [_vm._t("hooper-next", [_c('Icons', {
1225
- attrs: {
1226
- "name": _vm.isVertical ? 'arrowDown' : _vm.isRTL ? 'arrowLeft' : 'arrowRight'
1227
- }
1228
- })])], 2)]);
1108
+ var config = {
1109
+ isRTL: this.$hooper.config.rtl,
1110
+ isVertical: this.$hooper.config.vertical
1111
+ };
1112
+ var children = [renderButton(h, this.isPrevDisabled, this.$slots['hooper-prev'], true, config, function () {
1113
+ return _this.slidePrev();
1114
+ }), renderButton(h, this.isNextDisabled, this.$slots['hooper-next'], false, config, function () {
1115
+ return _this.slideNext();
1116
+ })];
1117
+ return h('div', {
1118
+ class: {
1119
+ 'hooper-navigation': true,
1120
+ 'is-vertical': this.$hooper.config.vertical,
1121
+ 'is-rtl': this.$hooper.config.rtl
1122
+ }
1123
+ }, children);
1124
+ }
1229
1125
  };
1230
1126
 
1231
- var __vue_staticRenderFns__$4 = [];
1232
- /* style */
1233
-
1234
- var __vue_inject_styles__$4 = undefined;
1235
- /* scoped */
1236
-
1237
- var __vue_scope_id__$4 = undefined;
1238
- /* module identifier */
1239
-
1240
- var __vue_module_identifier__$4 = undefined;
1241
- /* functional template */
1242
-
1243
- var __vue_is_functional_template__$4 = false;
1244
- /* style inject */
1245
-
1246
- /* style inject SSR */
1247
-
1248
- var Navigation = normalizeComponent_1({
1249
- render: __vue_render__$4,
1250
- staticRenderFns: __vue_staticRenderFns__$4
1251
- }, __vue_inject_styles__$4, __vue_script__$4, __vue_scope_id__$4, __vue_is_functional_template__$4, __vue_module_identifier__$4, undefined, undefined);
1252
-
1253
- export default Hooper;
1254
- export { Hooper, Icons, Navigation, Pagination, Progress, Slide, Mixin as addonMixin };
1127
+ export default Carousel;
1128
+ export { Carousel as Hooper, Icon, Navigation, Pagination, Progress, Slide, Mixin as addonMixin };