mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 12:09:26 +00:00
feat: add nav indicators wip wip wip fix: minor fixes fix: minor fixes fix: some refactor chore: update docs chore: update docs fix: remove slide component feat: create sl-carousel-item feat: code refactoring and improvements chore: update docs with more examples chore: fix docs feat: add autoplay feat: implement accessibility fix: change icons for rtl chore: minor change feat: improve accessibility fix: minor regression fix: minor regression chore: fix docs fix: improve accessibility and minor fixes fix: remove heading and refactor component chore: add custom style exmaple fix: address review commnets * Removed header from carousel * Added `ArrowUp` and `ArrowDown` in keyboard navigation * Added `--scroll-hint-margin` css property * Added an example with customized carousel layout * Fixed thumbnails navigation in demo * Renamed show-controls to show-arrows and updated the corresponding parts/css accordingly * Changed `activeSlideElement` getter to a private method * Changed pagination colors * Added `--slide-width` and `--slide-height` css properties chore: update docs fix: integrate latest repo changes fix: add aspect ratio and rebase chore: remove ignore path feat: multiple slides per page feat: multiple slide per page fix: various improvements chore: minor changes chore: minor changes chore: add bit of documentation chore: improve documentation fix: add unit tests and fix minor issues chore: update documentation and unit tests chore: update tests
31 lines
865 B
TypeScript
31 lines
865 B
TypeScript
// @debounce decorator
|
|
//
|
|
// Delays the execution until the provided delay in milliseconds has
|
|
// passed since the last time the function has been called.
|
|
//
|
|
//
|
|
// Usage:
|
|
//
|
|
// @debounce(1000)
|
|
// handleInput() {
|
|
// ...
|
|
// }
|
|
//
|
|
|
|
// Each class instance will need to store its timer id, so this unique symbol will be used as property key.
|
|
const TIMERID_KEY = Symbol();
|
|
|
|
export const debounce = (delay: number) => {
|
|
return <T>(_target: T, _propertyKey: string, descriptor: PropertyDescriptor) => {
|
|
const fn = descriptor.value as (this: T & { [TIMERID_KEY]: number }, ...args: unknown[]) => unknown;
|
|
|
|
descriptor.value = function (this: ThisParameterType<typeof fn>, ...args: Parameters<typeof fn>) {
|
|
clearTimeout(this[TIMERID_KEY]);
|
|
|
|
this[TIMERID_KEY] = window.setTimeout(() => {
|
|
fn.apply(this, args);
|
|
}, delay);
|
|
};
|
|
};
|
|
};
|