Skip to content

Commit

Permalink
1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Norman Rusch committed Feb 21, 2023
1 parent 2cf8827 commit 3683022
Show file tree
Hide file tree
Showing 22 changed files with 94 additions and 95 deletions.
4 changes: 2 additions & 2 deletions dist/carousel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export { Mask };
/**
* The available options for the carousel.
*/
export declare type Options = {
export type Options = {
index?: Index | number;
features?: IFeature[];
filterItem?: FilterItemFn;
Expand All @@ -17,7 +17,7 @@ export declare type Options = {
* The required configuration of the carousel.
* @internal
*/
export declare type Configuration = Omit<Required<Options>, 'index'>;
export type Configuration = Omit<Required<Options>, 'index'>;
/**
* The carousel instance.
*/
Expand Down
33 changes: 19 additions & 14 deletions dist/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ const DEFAULTS = {
* The carousel instance.
*/
export class Carousel {
/**
* This will be used for testing purposes to reset the instance count which is
* used to create unique id's.
* @internal
*/
static resetInstanceCount() {
/* This should not be part of the coverage report: test util */
/* istanbul ignore next */
if (process.env.NODE_ENV === 'test') {
__instanceCount = 0;
}
}
/**
* Creates an instance.
* @param el is the dom element to control. This should be a container element
Expand Down Expand Up @@ -92,32 +104,25 @@ export class Carousel {
break;
}
this.behavior = ScrollBehavior.SMOOTH;
// Events:
// Debounced events:
//
// Where do these magic numbers come from? The numbers are the results of
// testing the behavior in several browsers and are considered at "best fit"
// without visible side effects to the UI. The value for the "scroll" event
// correlates with the timing of scroll-behaviour: smooth.
//
// We disable @typescript-eslint/unbound-method here because we already bound
// the functions while creating a debounced version. This would also cause
// reference errors when tying to access these function references when used
// with removeEventListeners() (see: destroy())
//
/* eslint-disable @typescript-eslint/unbound-method */
this._onScroll = debounce(this._onScroll.bind(this), 25);
this._onScroll = debounce(this._onScroll.bind(this), 45);
this._onResize = debounce(this._onResize.bind(this), 25);
el.addEventListener(EVENT_SCROLL, this._onScroll);
window.addEventListener(EVENT_RESIZE, this._onResize);
/* eslint-enable @typescript-eslint/unbound-method */
}
/**
* This will be used for testing purposes to reset the instance count which is
* used to create unique id's.
* @internal
*/
static resetInstanceCount() {
/* This should not be part of the coverage report: test util */
/* istanbul ignore next */
if (process.env.NODE_ENV === 'test') {
__instanceCount = 0;
}
}
/**
* Returns the dom element reference of the carousel which was passed into the
* constructor.
Expand Down
6 changes: 3 additions & 3 deletions dist/features/buttons/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ declare const FEATURE_NAME = "buildin:buttons";
* @param context the template context containing the required data to render
* @return the HTML markup
*/
export declare type Template = (context: Context) => string;
export type Template = (context: Context) => string;
/**
* The template rendering context.
*/
export declare type Context = {
export type Context = {
controls: string;
className: string;
label: string;
Expand All @@ -18,7 +18,7 @@ export declare type Context = {
/**
* The options for the buttons feature.
*/
export declare type Options = {
export type Options = {
/**
* Render function for a single button.
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/features/mask/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ declare const FEATURE_NAME = "buildin:mask";
/**
* The options for the mask and scrollbar features.
*/
export declare type Options = {
export type Options = {
/**
* Enables/disables the rendering of the mask to hide (enabled) or show
* (disabled) the browsers scrollbars.
Expand Down
2 changes: 1 addition & 1 deletion dist/features/mask/scrollbar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Dataset of scrollbar dimensions
* @internal
*/
export declare type ScrollbarDimensions = {
export type ScrollbarDimensions = {
/**
* Vertical size of a scrollbar.
*/
Expand Down
4 changes: 2 additions & 2 deletions dist/features/mouse/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ declare const FEATURE_NAME = "buildin:mouse";
/**
* The options for the pagination feature.
*/
export declare type Options = {
export type Options = {
/**
* Show a drag indicator using css cursor properties (grab and grabbing).
*/
Expand All @@ -24,7 +24,7 @@ export declare type Options = {
/**
* The event object that is passed for each hook.
*/
export declare type HookEvent = {
export type HookEvent = {
originalEvent: Event;
};
/**
Expand Down
10 changes: 5 additions & 5 deletions dist/features/pagination/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ declare const FEATURE_NAME = "buildin:pagination";
* @param context the template context containing the required data to render
* @return the HTML markup
*/
export declare type Template = (params: Context) => string;
export type Template = (params: Context) => string;
/**
* The template rendering context.
*/
export declare type Context = {
export type Context = {
controls: string;
className: string;
label: TextTemplate;
Expand All @@ -20,19 +20,19 @@ export declare type Context = {
* A text template function to render a text node. This will be used for button
* labels and text-attributes inside the pagination
*/
export declare type TextTemplate = (params: TextContext) => string;
export type TextTemplate = (params: TextContext) => string;
/**
* The text template rendering context.
*/
export declare type TextContext = {
export type TextContext = {
index: number;
page: number[];
pages: number[][];
};
/**
* The options for the pagination feature.
*/
export declare type Options = {
export type Options = {
/**
* Render function for the pagination elemements.
*/
Expand Down
25 changes: 12 additions & 13 deletions dist/formats/cjs/caroucssel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,29 @@ function __rest(s, e) {

const __CACHE = new WeakMap();
function fromCache(ref, key, factory) {
const storage = __CACHE.get(ref) || {};
if (key in storage) {
return storage[key];
const storage = __CACHE.get(ref) || new Map();
if (storage.has(key)) {
return storage.get(key);
}
if (!factory) {
return undefined;
}
const value = factory();
storage[key] = value;
storage.set(key, value);
__CACHE.set(ref, storage);
return value;
}
function writeCache(ref, key, value) {
const storage = __CACHE.get(ref) || {};
storage[key] = value;
const storage = __CACHE.get(ref) || new Map();
storage.set(key, value);
__CACHE.set(ref, storage);
}
function clearCache(ref, key) {
const storage = __CACHE.get(ref);
if (!storage) {
if (!storage || !storage.has(key)) {
return;
}
storage[key] = undefined;
delete (storage[key]);
storage.delete(key);
}
function clearFullCache(ref) {
__CACHE.delete(ref);
Expand Down Expand Up @@ -593,6 +592,8 @@ const DEFAULTS = {
onScroll: () => undefined,
};
class Carousel {
static resetInstanceCount() {
}
constructor(el, options = {}) {
this.behavior = exports.ScrollBehavior.AUTO;
if (!el || !(el instanceof Element)) {
Expand Down Expand Up @@ -627,13 +628,11 @@ class Carousel {
break;
}
this.behavior = exports.ScrollBehavior.SMOOTH;
this._onScroll = debounce(this._onScroll.bind(this), 25);
this._onScroll = debounce(this._onScroll.bind(this), 45);
this._onResize = debounce(this._onResize.bind(this), 25);
el.addEventListener(EVENT_SCROLL, this._onScroll);
window.addEventListener(EVENT_RESIZE, this._onResize);
}
static resetInstanceCount() {
}
get el() {
return fromCache(this, CACHE_KEY_ELEMENT);
}
Expand Down Expand Up @@ -799,7 +798,7 @@ class Carousel {
}
}

const version = '1.1.1';
const version = '1.1.2';

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

0 comments on commit 3683022

Please sign in to comment.