Skip to content

Commit

Permalink
Build
Browse files Browse the repository at this point in the history
  • Loading branch information
Norman Rusch committed Sep 21, 2021
1 parent f0d2abb commit 717ca22
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 44 deletions.
2 changes: 1 addition & 1 deletion dist/caroucssel.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Index, Options, Pages } from './types';
import { Index, Options, Pages, ScrollBehavior } from './types';
export * from './types';
/**
* The carousel javascript instance.
Expand Down
6 changes: 3 additions & 3 deletions dist/caroucssel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Mask } from './plugins/mask';
import { ScrollBehaviour, UpdateReason } from './types';
import { ScrollBehavior, UpdateReason } from './types';
import { clearCache, clearFullCache, fromCache, writeCache } from './utils/cache';
import { debounce } from './utils/debounce';
// Export all types
Expand Down Expand Up @@ -92,7 +92,7 @@ export class Carousel {
* * `'auto'`
* * `'smooth'`
*/
this.behavior = ScrollBehaviour.AUTO;
this.behavior = ScrollBehavior.AUTO;
if (!el || !(el instanceof Element)) {
throw new Error(`Carousel needs a dom element but "${(typeof el)}" was passed.`);
}
Expand Down Expand Up @@ -131,7 +131,7 @@ export class Carousel {
this.index = [options.index];
break;
}
this.behavior = ScrollBehaviour.SMOOTH;
this.behavior = ScrollBehavior.SMOOTH;
// Events:
//
// We disable @typescript-eslint/unbound-method here because we already bound
Expand Down
1 change: 0 additions & 1 deletion dist/caroucssel.min.js

This file was deleted.

52 changes: 34 additions & 18 deletions dist/caroucssel.cjs.js → dist/formats/cjs/caroucssel.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,18 @@ class Buttons {
}
}

var UpdateReason;
exports.UpdateReason = void 0;
(function (UpdateReason) {
UpdateReason["SCROLL"] = "scroll";
UpdateReason["RESIZE"] = "resize";
UpdateReason["FORCED"] = "forced";
UpdateReason["PLUGIN"] = "plugin";
})(UpdateReason || (UpdateReason = {}));
var ScrollBehaviour;
(function (ScrollBehaviour) {
ScrollBehaviour["AUTO"] = "auto";
ScrollBehaviour["SMOOTH"] = "smooth";
})(ScrollBehaviour || (ScrollBehaviour = {}));
})(exports.UpdateReason || (exports.UpdateReason = {}));
exports.ScrollBehavior = void 0;
(function (ScrollBehavior) {
ScrollBehavior["AUTO"] = "auto";
ScrollBehavior["SMOOTH"] = "smooth";
})(exports.ScrollBehavior || (exports.ScrollBehavior = {}));

class Scrollbar {
constructor() {
Expand Down Expand Up @@ -240,8 +240,8 @@ class Mask {
}
update(data) {
switch (data.reason) {
case UpdateReason.RESIZE:
case UpdateReason.FORCED:
case exports.UpdateReason.RESIZE:
case exports.UpdateReason.FORCED:
clearCache(this, CACHE_KEY_HEIGHT);
this._render();
break;
Expand Down Expand Up @@ -289,6 +289,21 @@ class Mask {
}
}

class Mouse {
get name() {
return 'buildin:mouse';
}
init(proxy) {
writeCache(this, 'proxy', proxy);
}
destroy() {
console.log('Destroy mouse');
}
update(data) {
console.log('Update mouse:', data.reason);
}
}

const DEFAULTS$1 = {
template: ({ className, controls, pages, label, title }) => `
<ul class="${className}">
Expand Down Expand Up @@ -330,7 +345,7 @@ class Pagination {
}
update(data) {
switch (data.reason) {
case UpdateReason.SCROLL:
case exports.UpdateReason.SCROLL:
this._update();
break;
default:
Expand Down Expand Up @@ -465,7 +480,7 @@ class Proxy {
}
class Carousel {
constructor(el, options = {}) {
this.behavior = ScrollBehaviour.AUTO;
this.behavior = exports.ScrollBehavior.AUTO;
if (!el || !(el instanceof Element)) {
throw new Error(`Carousel needs a dom element but "${(typeof el)}" was passed.`);
}
Expand Down Expand Up @@ -495,7 +510,7 @@ class Carousel {
this.index = [options.index];
break;
}
this.behavior = ScrollBehaviour.SMOOTH;
this.behavior = exports.ScrollBehavior.SMOOTH;
this._onScroll = debounce(this._onScroll.bind(this), 25);
this._onResize = debounce(this._onResize.bind(this), 25);
el.addEventListener(EVENT_SCROLL, this._onScroll);
Expand Down Expand Up @@ -651,13 +666,13 @@ class Carousel {
clearCache(this, CACHE_KEY_PAGES);
clearCache(this, CACHE_KEY_PAGE_INDEX);
const plugins = fromCache(this, CACHE_KEY_PLUGINS);
plugins === null || plugins === void 0 ? void 0 : plugins.forEach((plugin) => plugin.update({ reason: UpdateReason.FORCED }));
plugins === null || plugins === void 0 ? void 0 : plugins.forEach((plugin) => plugin.update({ reason: exports.UpdateReason.FORCED }));
}
_onScroll(event) {
clearCache(this, CACHE_KEY_INDEX);
clearCache(this, CACHE_KEY_PAGE_INDEX);
const plugins = fromCache(this, CACHE_KEY_PLUGINS);
plugins === null || plugins === void 0 ? void 0 : plugins.forEach((plugin) => plugin.update({ reason: UpdateReason.SCROLL }));
plugins === null || plugins === void 0 ? void 0 : plugins.forEach((plugin) => plugin.update({ reason: exports.UpdateReason.SCROLL }));
const { index } = this;
const configuration = fromCache(this, CACHE_KEY_CONFIGURATION);
configuration === null || configuration === void 0 ? void 0 : configuration.onScroll({ index, type: EVENT_SCROLL, target: this, originalEvent: event });
Expand All @@ -667,11 +682,12 @@ class Carousel {
clearCache(this, CACHE_KEY_INDEX);
clearCache(this, CACHE_KEY_PAGE_INDEX);
const plugins = fromCache(this, CACHE_KEY_PLUGINS);
plugins === null || plugins === void 0 ? void 0 : plugins.forEach((plugin) => plugin.update({ reason: UpdateReason.RESIZE }));
plugins === null || plugins === void 0 ? void 0 : plugins.forEach((plugin) => plugin.update({ reason: exports.UpdateReason.RESIZE }));
}
}

const plugins = { Buttons, Mask, Pagination };

exports.Buttons = Buttons;
exports.Carousel = Carousel;
exports.plugins = plugins;
exports.Mask = Mask;
exports.Mouse = Mouse;
exports.Pagination = Pagination;
Loading

0 comments on commit 717ca22

Please sign in to comment.