Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Norman Rusch committed Nov 8, 2021
1 parent 5c8a806 commit 88f4650
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 55 deletions.
2 changes: 1 addition & 1 deletion dist/features/buttons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class Buttons {
*/
_remove() {
const buttons = fromCache(this, CACHE_KEY_BUTTONS);
buttons.forEach((button) => {
buttons === null || buttons === void 0 ? void 0 : buttons.forEach((button) => {
var _a;
// The onClick listener is already bound in the constructor.
//
Expand Down
18 changes: 9 additions & 9 deletions dist/features/mouse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,28 +122,28 @@ export class Mouse {
* @param event the event that triggered the dragging
*/
_onDrag(event) {
var _a;
var _a, _b, _c;
const config = fromCache(this, CACHE_KEY_CONFIGURATION);
const { el } = fromCache(this, CACHE_KEY_PROXY);
const left = fromCache(this, CACHE_KEY_SCROLL_LEFT);
const x = fromCache(this, CACHE_KEY_POSITION_X);
const left = (_a = fromCache(this, CACHE_KEY_SCROLL_LEFT)) !== null && _a !== void 0 ? _a : 0;
const x = (_b = fromCache(this, CACHE_KEY_POSITION_X)) !== null && _b !== void 0 ? _b : 0;
const currentX = __getPositionX(event);
const deltaX = x - currentX;
el.scrollLeft = left + deltaX;
// Call the hook:
(_a = config.onDrag) === null || _a === void 0 ? void 0 : _a.call(config, { originalEvent: event });
(_c = config.onDrag) === null || _c === void 0 ? void 0 : _c.call(config, { originalEvent: event });
}
/**
* Handles the drag end event.
* @internal
* @param event the event that triggered the drag end
*/
_onEnd(event) {
var _a, _b;
var _a, _b, _c, _d;
const proxy = fromCache(this, CACHE_KEY_PROXY);
const config = fromCache(this, CACHE_KEY_CONFIGURATION);
const left = fromCache(this, CACHE_KEY_SCROLL_LEFT);
const pageIndex = fromCache(this, CACHE_KEY_PAGE_INDEX);
const left = (_a = fromCache(this, CACHE_KEY_SCROLL_LEFT)) !== null && _a !== void 0 ? _a : 0;
const pageIndex = (_b = fromCache(this, CACHE_KEY_PAGE_INDEX)) !== null && _b !== void 0 ? _b : 0;
clearCache(this, CACHE_KEY_SCROLL_LEFT);
clearCache(this, CACHE_KEY_POSITION_X);
clearCache(this, CACHE_KEY_PAGE_INDEX);
Expand All @@ -161,7 +161,7 @@ export class Mouse {
if (offset > threshold) {
const direction = distance / offset;
const at = Math.max(pageIndex + direction, 0);
index = (_a = proxy.pages[at]) !== null && _a !== void 0 ? _a : index;
index = (_c = proxy.pages[at]) !== null && _c !== void 0 ? _c : index;
}
// Apply the index until the styles are rendered to the element. This is
// required to have a smooth scroll-behaviour which is disabled during the
Expand All @@ -183,6 +183,6 @@ export class Mouse {
window.removeEventListener(EVENT_END, this._onEnd);
/* eslint-enable @typescript-eslint/unbound-method */
// Call the hook:
(_b = config.onEnd) === null || _b === void 0 ? void 0 : _b.call(config, { originalEvent: event });
(_d = config.onEnd) === null || _d === void 0 ? void 0 : _d.call(config, { originalEvent: event });
}
}
5 changes: 4 additions & 1 deletion dist/features/pagination/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class Pagination {
const proxy = fromCache(this, CACHE_KEY_PROXY);
const buttons = fromCache(this, CACHE_KEY_BUTTONS);
const { pageIndex } = proxy;
buttons.forEach((button, at) => button.disabled = (at === pageIndex));
buttons === null || buttons === void 0 ? void 0 : buttons.forEach((button, at) => button.disabled = (at === pageIndex));
}
/**
* Removes the whole pagination element and removes all attached event handlers.
Expand Down Expand Up @@ -158,6 +158,9 @@ export class Pagination {
_onClick(event) {
const proxy = fromCache(this, CACHE_KEY_PROXY);
const buttons = fromCache(this, CACHE_KEY_BUTTONS);
if (!buttons) {
return;
}
const target = event.currentTarget;
const index = buttons.indexOf(target);
proxy.index = proxy.pages[index];
Expand Down
27 changes: 15 additions & 12 deletions dist/formats/cjs/caroucssel.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Buttons {
}
_remove() {
const buttons = fromCache(this, CACHE_KEY_BUTTONS$1);
buttons.forEach((button) => {
buttons === null || buttons === void 0 ? void 0 : buttons.forEach((button) => {
var _a;
button === null || button === void 0 ? void 0 : button.removeEventListener(EVENT_CLICK, this._onPrev);
button === null || button === void 0 ? void 0 : button.removeEventListener(EVENT_CLICK, this._onNext);
Expand Down Expand Up @@ -229,22 +229,22 @@ class Mouse {
(_a = config.onStart) === null || _a === void 0 ? void 0 : _a.call(config, { originalEvent: event });
}
_onDrag(event) {
var _a;
var _a, _b, _c;
const config = fromCache(this, CACHE_KEY_CONFIGURATION$3);
const { el } = fromCache(this, CACHE_KEY_PROXY$3);
const left = fromCache(this, CACHE_KEY_SCROLL_LEFT);
const x = fromCache(this, CACHE_KEY_POSITION_X);
const left = (_a = fromCache(this, CACHE_KEY_SCROLL_LEFT)) !== null && _a !== void 0 ? _a : 0;
const x = (_b = fromCache(this, CACHE_KEY_POSITION_X)) !== null && _b !== void 0 ? _b : 0;
const currentX = __getPositionX(event);
const deltaX = x - currentX;
el.scrollLeft = left + deltaX;
(_a = config.onDrag) === null || _a === void 0 ? void 0 : _a.call(config, { originalEvent: event });
(_c = config.onDrag) === null || _c === void 0 ? void 0 : _c.call(config, { originalEvent: event });
}
_onEnd(event) {
var _a, _b;
var _a, _b, _c, _d;
const proxy = fromCache(this, CACHE_KEY_PROXY$3);
const config = fromCache(this, CACHE_KEY_CONFIGURATION$3);
const left = fromCache(this, CACHE_KEY_SCROLL_LEFT);
const pageIndex = fromCache(this, CACHE_KEY_PAGE_INDEX$1);
const left = (_a = fromCache(this, CACHE_KEY_SCROLL_LEFT)) !== null && _a !== void 0 ? _a : 0;
const pageIndex = (_b = fromCache(this, CACHE_KEY_PAGE_INDEX$1)) !== null && _b !== void 0 ? _b : 0;
clearCache(this, CACHE_KEY_SCROLL_LEFT);
clearCache(this, CACHE_KEY_POSITION_X);
clearCache(this, CACHE_KEY_PAGE_INDEX$1);
Expand All @@ -260,7 +260,7 @@ class Mouse {
if (offset > threshold) {
const direction = distance / offset;
const at = Math.max(pageIndex + direction, 0);
index = (_a = proxy.pages[at]) !== null && _a !== void 0 ? _a : index;
index = (_c = proxy.pages[at]) !== null && _c !== void 0 ? _c : index;
}
window.requestAnimationFrame(() => {
proxy.index = index;
Expand All @@ -271,7 +271,7 @@ class Mouse {
writeCache(this, CACHE_KEY_TIMEOUT, timeout);
window.removeEventListener(EVENT_DRAG, this._onDrag);
window.removeEventListener(EVENT_END, this._onEnd);
(_b = config.onEnd) === null || _b === void 0 ? void 0 : _b.call(config, { originalEvent: event });
(_d = config.onEnd) === null || _d === void 0 ? void 0 : _d.call(config, { originalEvent: event });
}
}

Expand Down Expand Up @@ -367,7 +367,7 @@ class Pagination {
const proxy = fromCache(this, CACHE_KEY_PROXY$2);
const buttons = fromCache(this, CACHE_KEY_BUTTONS);
const { pageIndex } = proxy;
buttons.forEach((button, at) => button.disabled = (at === pageIndex));
buttons === null || buttons === void 0 ? void 0 : buttons.forEach((button, at) => button.disabled = (at === pageIndex));
}
_remove() {
var _a;
Expand All @@ -385,6 +385,9 @@ class Pagination {
_onClick(event) {
const proxy = fromCache(this, CACHE_KEY_PROXY$2);
const buttons = fromCache(this, CACHE_KEY_BUTTONS);
if (!buttons) {
return;
}
const target = event.currentTarget;
const index = buttons.indexOf(target);
proxy.index = proxy.pages[index];
Expand Down Expand Up @@ -796,7 +799,7 @@ class Carousel {
}
}

const version = '1.0.0';
const version = '1.0.1';

exports.Buttons = Buttons;
exports.Carousel = Carousel;
Expand Down
Loading

0 comments on commit 88f4650

Please sign in to comment.