Skip to content

Commit 26dd6ab

Browse files
committed
1.9.0
1 parent 82647f8 commit 26dd6ab

File tree

2 files changed

+27
-38
lines changed

2 files changed

+27
-38
lines changed

index.js

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,11 @@ module.exports =
8282
/******/
8383
/******/
8484
/******/ // Load entry module and return exports
85-
/******/ return __webpack_require__(__webpack_require__.s = 1);
85+
/******/ return __webpack_require__(__webpack_require__.s = 0);
8686
/******/ })
8787
/************************************************************************/
8888
/******/ ([
8989
/* 0 */
90-
/***/ (function(module, exports) {
91-
92-
module.exports = require("lodash/throttle");
93-
94-
/***/ }),
95-
/* 1 */
9690
/***/ (function(module, __webpack_exports__, __webpack_require__) {
9791

9892
"use strict";
@@ -918,15 +912,10 @@ Code related to auotplay features of the carousel
918912
}
919913
}
920914
});
921-
// EXTERNAL MODULE: external "lodash/throttle"
922-
var throttle_ = __webpack_require__(0);
923-
var throttle_default = /*#__PURE__*/__webpack_require__.n(throttle_);
924-
925915
// CONCATENATED MODULE: ./src/concerns/dimensions.coffee
926916
/*
927917
Code related to measuring the size of the carousel after mounting
928918
*/
929-
930919
/* harmony default export */ var dimensions_coffee = ({
931920
data: function () {
932921
return {
@@ -941,12 +930,11 @@ Code related to measuring the size of the carousel after mounting
941930
// Add resize listening
942931
mounted: function () {
943932
this.onResize();
944-
this.onResizeThrottled = throttle_default()(this.onResize, 200);
945-
return window.addEventListener('resize', this.onResizeThrottled);
933+
return window.addEventListener('resize', this.onResize);
946934
},
947935
// Cleanup listeners
948936
beforeDestroy: function () {
949-
return window.removeEventListener('resize', this.onResizeThrottled);
937+
return window.removeEventListener('resize', this.onResize);
950938
},
951939
computed: {
952940
// The width of a page of slides, which may be less than the carouselWidth
@@ -1724,14 +1712,15 @@ Code related to dealing with advancing between pages
17241712
}
17251713
},
17261714
watch: {
1727-
// Treat v-model input as a "goto" request. Immediately fire an input
1728-
// event if the index was not changed, like when an edge is reached, to
1729-
// update the parent component.
1715+
// Treat v-model input as a "goto" request
17301716
value: function () {
1731-
this.goto(this.value);
1732-
1733-
if (this.value !== this.boundedIndex) {
1734-
return this.$emit('input', this.boundedIndex);
1717+
// If the value exceeds the bounds, immediately emit a new input event
1718+
// with the corrected value
1719+
if (this.value !== this.applyIndexBoundaries(this.value)) {
1720+
return this.$emit('input', this.boundedIndex); // Else if the incoming value is different than the current value
1721+
// then tween to it
1722+
} else if (this.value !== this.boundedIndex) {
1723+
return this.goto(this.value);
17351724
}
17361725
},
17371726
// Emit events on index change
@@ -1779,14 +1768,21 @@ Code related to dealing with advancing between pages
17791768
},
17801769
// Tween to a specific index
17811770
tweenToIndex: function (index) {
1771+
this.targetX = this.getXForIndex(index);
1772+
return this.startTweening();
1773+
},
1774+
// Jump to an index with no tween
1775+
jumpToIndex: function (index) {
1776+
return this.currentX = this.targetX = this.getXForIndex(index);
1777+
},
1778+
// Calculate the X value given an index
1779+
getXForIndex: function (index) {
17821780
var x; // Figure out the new x position
17831781

17841782
x = this.paginateBySlide ? index * this.slideWidth * -1 : index * this.pageWidth * -1; // Apply adjustments to x value and persist
17851783

17861784
x += this.makeIncompletePageOffset(index);
1787-
this.targetX = Math.round(this.applyXBoundaries(x)); // Start tweening
1788-
1789-
return this.startTweening();
1785+
return Math.round(this.applyXBoundaries(x));
17901786
},
17911787
// Creates a px value to represent adjustments that should be made to
17921788
// account for incommplete pages of slides when looping is enabled. Like
@@ -2038,7 +2034,7 @@ Code related to changing the slides per page at different viewport widths
20382034
watch: {
20392035
// Fix alignment of slides while resizing
20402036
pageWidth: function () {
2041-
return this.tweenToIndex(this.index);
2037+
return this.jumpToIndex(this.index);
20422038
},
20432039
// If resizing the browser leads to disabling, reset the slide to the first
20442040
// page. Like if a user had switched to the 2nd page on mobile and then
@@ -2212,9 +2208,7 @@ Code related to tweening the position of the track
22122208
// The actual left offset of the slides container
22132209
targetX: 0,
22142210
// Where we may be tweening the slide to
2215-
tweening: false,
2216-
// If there is a current RAF based tween running
2217-
firstTween: true // Has the first tween been triggered
2211+
tweening: false // If there is a current RAF based tween running
22182212

22192213
};
22202214
},
@@ -2229,8 +2223,7 @@ Code related to tweening the position of the track
22292223
this.$emit('tween:start', {
22302224
index: this.index
22312225
});
2232-
this.tweenToTarget();
2233-
return this.firstTween = false;
2226+
return this.tweenToTarget();
22342227
} else {
22352228
window.cancelAnimationFrame(this.rafId);
22362229
return this.$emit('tween:end', {
@@ -2264,12 +2257,8 @@ Code related to tweening the position of the track
22642257
},
22652258
// Tween the currentX to the targetX
22662259
tweenToTarget: function () {
2267-
var dampening; // If on the first tween and the first page was set to something other
2268-
// than 0 by v-model, then instantly jump to the final destination
2269-
2270-
dampening = this.firstTween && this.value !== 0 ? 1 : this.tweenDampening; // Apply tween math
2271-
2272-
this.currentX = this.currentX + (this.targetX - this.currentX) * dampening;
2260+
// Apply tween math
2261+
this.currentX = this.currentX + (this.targetX - this.currentX) * this.tweenDampening;
22732262

22742263
if (Math.abs(this.targetX - this.currentX) < 1) {
22752264
// Stops tweening

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-ssr-carousel",
3-
"version": "1.8.0",
3+
"version": "1.9.0",
44
"description": "A performance focused Vue carousel designed for SSR/SSG environments.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)