@elementar-rt/components 0.6.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -0
- package/action-required/index.d.ts +13 -0
- package/alert/index.d.ts +51 -0
- package/announcement/index.d.ts +45 -0
- package/avatar/index.d.ts +67 -0
- package/block-loader/index.d.ts +21 -0
- package/block-state/index.d.ts +33 -0
- package/brand-colors/index.d.ts +27 -0
- package/breadcrumbs/index.d.ts +104 -0
- package/card-overlay/index.d.ts +20 -0
- package/carousel/index.d.ts +75 -0
- package/code-highlighter/index.d.ts +18 -0
- package/color-picker/index.d.ts +92 -0
- package/color-scheme/index.d.ts +44 -0
- package/command-bar/index.d.ts +28 -0
- package/comment-editor/index.d.ts +194 -0
- package/comparison-slider/index.d.ts +51 -0
- package/confirm/index.d.ts +35 -0
- package/content-fade/index.d.ts +17 -0
- package/cookie-popup/index.d.ts +41 -0
- package/core/index.d.ts +252 -0
- package/country-select/index.d.ts +76 -0
- package/crop/index.d.ts +59 -0
- package/currency-select/index.d.ts +78 -0
- package/dashboard/index.d.ts +48 -0
- package/data-view/index.d.ts +127 -0
- package/date-format-select/index.d.ts +56 -0
- package/divider/index.d.ts +13 -0
- package/drawer/index.d.ts +35 -0
- package/emoji-picker/index.d.ts +49 -0
- package/expand/index.d.ts +26 -0
- package/fesm2022/elementar-rt-components-action-required.mjs +30 -0
- package/fesm2022/elementar-rt-components-action-required.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-alert.mjs +139 -0
- package/fesm2022/elementar-rt-components-alert.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-announcement.mjs +73 -0
- package/fesm2022/elementar-rt-components-announcement.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-avatar.mjs +234 -0
- package/fesm2022/elementar-rt-components-avatar.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-block-loader.mjs +54 -0
- package/fesm2022/elementar-rt-components-block-loader.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-block-state.mjs +75 -0
- package/fesm2022/elementar-rt-components-block-state.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-brand-colors.mjs +78 -0
- package/fesm2022/elementar-rt-components-brand-colors.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-breadcrumbs.mjs +213 -0
- package/fesm2022/elementar-rt-components-breadcrumbs.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-card-overlay.mjs +55 -0
- package/fesm2022/elementar-rt-components-card-overlay.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-carousel.mjs +605 -0
- package/fesm2022/elementar-rt-components-carousel.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-code-highlighter.mjs +57 -0
- package/fesm2022/elementar-rt-components-code-highlighter.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-color-picker.mjs +708 -0
- package/fesm2022/elementar-rt-components-color-picker.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-color-scheme.mjs +106 -0
- package/fesm2022/elementar-rt-components-color-scheme.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-command-bar.mjs +59 -0
- package/fesm2022/elementar-rt-components-command-bar.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-comment-editor.mjs +1039 -0
- package/fesm2022/elementar-rt-components-comment-editor.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-comparison-slider.mjs +193 -0
- package/fesm2022/elementar-rt-components-comparison-slider.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-confirm.mjs +86 -0
- package/fesm2022/elementar-rt-components-confirm.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-content-fade.mjs +35 -0
- package/fesm2022/elementar-rt-components-content-fade.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-cookie-popup.mjs +109 -0
- package/fesm2022/elementar-rt-components-cookie-popup.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-core.mjs +837 -0
- package/fesm2022/elementar-rt-components-core.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-country-select.mjs +477 -0
- package/fesm2022/elementar-rt-components-country-select.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-crop.mjs +183 -0
- package/fesm2022/elementar-rt-components-crop.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-currency-select.mjs +384 -0
- package/fesm2022/elementar-rt-components-currency-select.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-dashboard.mjs +96 -0
- package/fesm2022/elementar-rt-components-dashboard.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-data-view.mjs +302 -0
- package/fesm2022/elementar-rt-components-data-view.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-date-format-select.mjs +136 -0
- package/fesm2022/elementar-rt-components-date-format-select.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-divider.mjs +31 -0
- package/fesm2022/elementar-rt-components-divider.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-drawer.mjs +131 -0
- package/fesm2022/elementar-rt-components-drawer.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-emoji-picker.mjs +249 -0
- package/fesm2022/elementar-rt-components-emoji-picker.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-expand.mjs +60 -0
- package/fesm2022/elementar-rt-components-expand.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-filter-builder.mjs +333 -0
- package/fesm2022/elementar-rt-components-filter-builder.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer-autocomplete-many-field.component-AqEghjO_.mjs +123 -0
- package/fesm2022/elementar-rt-components-form-renderer-autocomplete-many-field.component-AqEghjO_.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer-checkbox-field.component-CUKmZGFq.mjs +22 -0
- package/fesm2022/elementar-rt-components-form-renderer-checkbox-field.component-CUKmZGFq.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer-datepicker-field.component-DihIRWMt.mjs +40 -0
- package/fesm2022/elementar-rt-components-form-renderer-datepicker-field.component-DihIRWMt.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer-divider-content.component-CjlGcU3B.mjs +17 -0
- package/fesm2022/elementar-rt-components-form-renderer-divider-content.component-CjlGcU3B.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer-image-content.component-0pL2Fk0H.mjs +17 -0
- package/fesm2022/elementar-rt-components-form-renderer-image-content.component-0pL2Fk0H.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer-input-field.component-X2sKvj6J.mjs +33 -0
- package/fesm2022/elementar-rt-components-form-renderer-input-field.component-X2sKvj6J.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer-radio-group-field.component-DWXZAA3F.mjs +38 -0
- package/fesm2022/elementar-rt-components-form-renderer-radio-group-field.component-DWXZAA3F.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer-select-field.component-Cx9DZoD6.mjs +39 -0
- package/fesm2022/elementar-rt-components-form-renderer-select-field.component-Cx9DZoD6.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer-text-content.component-BmFyUG06.mjs +24 -0
- package/fesm2022/elementar-rt-components-form-renderer-text-content.component-BmFyUG06.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer-textarea-field.component-D9KmE049.mjs +37 -0
- package/fesm2022/elementar-rt-components-form-renderer-textarea-field.component-D9KmE049.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer-timezone-field.component-BroP_Q4P.mjs +35 -0
- package/fesm2022/elementar-rt-components-form-renderer-timezone-field.component-BroP_Q4P.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer-toggle-field.component-nGbtVi1_.mjs +22 -0
- package/fesm2022/elementar-rt-components-form-renderer-toggle-field.component-nGbtVi1_.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-form-renderer.mjs +321 -0
- package/fesm2022/elementar-rt-components-form-renderer.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-gauge.mjs +50 -0
- package/fesm2022/elementar-rt-components-gauge.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-icon.mjs +62 -0
- package/fesm2022/elementar-rt-components-icon.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-image-resizer.mjs +159 -0
- package/fesm2022/elementar-rt-components-image-resizer.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-image-viewer.mjs +349 -0
- package/fesm2022/elementar-rt-components-image-viewer.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-incidents.mjs +259 -0
- package/fesm2022/elementar-rt-components-incidents.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-inline-text-edit.mjs +181 -0
- package/fesm2022/elementar-rt-components-inline-text-edit.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-input-mask.mjs +180 -0
- package/fesm2022/elementar-rt-components-input-mask.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-input-validator.mjs +24 -0
- package/fesm2022/elementar-rt-components-input-validator.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-kanban-board.mjs +156 -0
- package/fesm2022/elementar-rt-components-kanban-board.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-layout.mjs +188 -0
- package/fesm2022/elementar-rt-components-layout.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-logo.mjs +43 -0
- package/fesm2022/elementar-rt-components-logo.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-marquee.mjs +79 -0
- package/fesm2022/elementar-rt-components-marquee.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-micro-chart.mjs +950 -0
- package/fesm2022/elementar-rt-components-micro-chart.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-navigation.mjs +379 -0
- package/fesm2022/elementar-rt-components-navigation.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-notifications.mjs +190 -0
- package/fesm2022/elementar-rt-components-notifications.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-number-input.mjs +288 -0
- package/fesm2022/elementar-rt-components-number-input.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-overlay-scrollbar.mjs +455 -0
- package/fesm2022/elementar-rt-components-overlay-scrollbar.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-overlay.mjs +112 -0
- package/fesm2022/elementar-rt-components-overlay.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-page-loading-bar.mjs +79 -0
- package/fesm2022/elementar-rt-components-page-loading-bar.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-panel.mjs +105 -0
- package/fesm2022/elementar-rt-components-panel.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-password-strength.mjs +474 -0
- package/fesm2022/elementar-rt-components-password-strength.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-phone-input.mjs +637 -0
- package/fesm2022/elementar-rt-components-phone-input.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-pin-input.mjs +197 -0
- package/fesm2022/elementar-rt-components-pin-input.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-popover.mjs +262 -0
- package/fesm2022/elementar-rt-components-popover.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-radio-card.mjs +102 -0
- package/fesm2022/elementar-rt-components-radio-card.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-rail-nav.mjs +84 -0
- package/fesm2022/elementar-rt-components-rail-nav.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-resizable-container.mjs +69 -0
- package/fesm2022/elementar-rt-components-resizable-container.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-screen-loader.mjs +27 -0
- package/fesm2022/elementar-rt-components-screen-loader.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-scroll-spy.mjs +165 -0
- package/fesm2022/elementar-rt-components-scroll-spy.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-segmented.mjs +153 -0
- package/fesm2022/elementar-rt-components-segmented.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-side-panel.mjs +110 -0
- package/fesm2022/elementar-rt-components-side-panel.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-sidebar.mjs +423 -0
- package/fesm2022/elementar-rt-components-sidebar.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-signature-pad.mjs +452 -0
- package/fesm2022/elementar-rt-components-signature-pad.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-skeleton.mjs +56 -0
- package/fesm2022/elementar-rt-components-skeleton.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-splash-screen.mjs +91 -0
- package/fesm2022/elementar-rt-components-splash-screen.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-stepper.mjs +194 -0
- package/fesm2022/elementar-rt-components-stepper.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-suggestions.mjs +76 -0
- package/fesm2022/elementar-rt-components-suggestions.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-tab-panel.mjs +270 -0
- package/fesm2022/elementar-rt-components-tab-panel.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-text-editor.mjs +1025 -0
- package/fesm2022/elementar-rt-components-text-editor.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-thumbnail-maker.mjs +214 -0
- package/fesm2022/elementar-rt-components-thumbnail-maker.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-timeline.mjs +122 -0
- package/fesm2022/elementar-rt-components-timeline.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-timezone-select.mjs +351 -0
- package/fesm2022/elementar-rt-components-timezone-select.mjs.map +1 -0
- package/fesm2022/elementar-rt-components-upload.mjs +340 -0
- package/fesm2022/elementar-rt-components-upload.mjs.map +1 -0
- package/fesm2022/elementar-rt-components.mjs +6 -0
- package/fesm2022/elementar-rt-components.mjs.map +1 -0
- package/filter-builder/index.d.ts +107 -0
- package/form-renderer/index.d.ts +121 -0
- package/gauge/index.d.ts +21 -0
- package/icon/index.d.ts +17 -0
- package/image-resizer/index.d.ts +35 -0
- package/image-viewer/index.d.ts +63 -0
- package/incidents/index.d.ts +119 -0
- package/index.d.ts +2 -0
- package/inline-text-edit/index.d.ts +39 -0
- package/input-mask/index.d.ts +36 -0
- package/input-validator/index.d.ts +5 -0
- package/kanban-board/index.d.ts +68 -0
- package/layout/index.d.ts +75 -0
- package/logo/index.d.ts +21 -0
- package/marquee/index.d.ts +26 -0
- package/micro-chart/index.d.ts +193 -0
- package/navigation/index.d.ts +119 -0
- package/notifications/index.d.ts +84 -0
- package/number-input/index.d.ts +93 -0
- package/overlay/index.d.ts +12 -0
- package/overlay-scrollbar/index.d.ts +66 -0
- package/package.json +356 -0
- package/page-loading-bar/index.d.ts +20 -0
- package/panel/index.d.ts +43 -0
- package/password-strength/index.d.ts +109 -0
- package/phone-input/index.d.ts +94 -0
- package/pin-input/index.d.ts +48 -0
- package/popover/index.d.ts +75 -0
- package/radio-card/index.d.ts +37 -0
- package/rail-nav/index.d.ts +36 -0
- package/resizable-container/index.d.ts +21 -0
- package/screen-loader/index.d.ts +9 -0
- package/scroll-spy/index.d.ts +48 -0
- package/segmented/index.d.ts +54 -0
- package/side-panel/index.d.ts +42 -0
- package/sidebar/index.d.ts +143 -0
- package/signature-pad/index.d.ts +49 -0
- package/skeleton/index.d.ts +24 -0
- package/splash-screen/index.d.ts +31 -0
- package/stepper/index.d.ts +65 -0
- package/styles/_common.scss +776 -0
- package/styles/themes/cyan-orange.scss +41 -0
- package/styles/themes/default.scss +5 -0
- package/styles/themes/magenta-violet.scss +41 -0
- package/styles/themes/rose-red.scss +41 -0
- package/suggestions/index.d.ts +32 -0
- package/tab-panel/index.d.ts +96 -0
- package/text-editor/index.d.ts +191 -0
- package/thumbnail-maker/index.d.ts +35 -0
- package/timeline/index.d.ts +57 -0
- package/timezone-select/index.d.ts +72 -0
- package/upload/index.d.ts +134 -0
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, input, output, signal, inject, ElementRef, Renderer2, NgZone, Directive, viewChild, contentChildren, booleanAttribute, Component } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
const CAROUSEL = new InjectionToken('CAROUSEL');
|
|
5
|
+
const CAROUSEL_CARD = new InjectionToken('CAROUSEL_CARD');
|
|
6
|
+
|
|
7
|
+
function easeOutQuad(t) {
|
|
8
|
+
return t * (2 - t);
|
|
9
|
+
}
|
|
10
|
+
class DraggableCarouselDirective {
|
|
11
|
+
cardSelector = input('.emr-carousel-card', ...(ngDevMode ? [{ debugName: "cardSelector" }] : []));
|
|
12
|
+
snapToCenter = input(true, ...(ngDevMode ? [{ debugName: "snapToCenter" }] : []));
|
|
13
|
+
snapDebounceTime = input(50, ...(ngDevMode ? [{ debugName: "snapDebounceTime" }] : []));
|
|
14
|
+
snapDuration = input(300, ...(ngDevMode ? [{ debugName: "snapDuration" }] : []));
|
|
15
|
+
resistanceFactor = input(0.5, ...(ngDevMode ? [{ debugName: "resistanceFactor" }] : []));
|
|
16
|
+
velocityThreshold = input(0.5, ...(ngDevMode ? [{ debugName: "velocityThreshold" }] : []));
|
|
17
|
+
visibilityDebounceTime = input(100, ...(ngDevMode ? [{ debugName: "visibilityDebounceTime" }] : []));
|
|
18
|
+
indexChange = output();
|
|
19
|
+
isDragging = signal(false, ...(ngDevMode ? [{ debugName: "isDragging" }] : []));
|
|
20
|
+
startX = signal(0, ...(ngDevMode ? [{ debugName: "startX" }] : []));
|
|
21
|
+
scrollLeftStart = signal(0, ...(ngDevMode ? [{ debugName: "scrollLeftStart" }] : []));
|
|
22
|
+
currentTranslateX = signal(0, ...(ngDevMode ? [{ debugName: "currentTranslateX" }] : []));
|
|
23
|
+
lastMoveX = signal(null, ...(ngDevMode ? [{ debugName: "lastMoveX" }] : []));
|
|
24
|
+
lastMoveTime = signal(null, ...(ngDevMode ? [{ debugName: "lastMoveTime" }] : []));
|
|
25
|
+
currentVelocityX = signal(0, ...(ngDevMode ? [{ debugName: "currentVelocityX" }] : []));
|
|
26
|
+
lastEmittedIndex = signal(null, ...(ngDevMode ? [{ debugName: "lastEmittedIndex" }] : []));
|
|
27
|
+
snapTimeoutId = null;
|
|
28
|
+
scrollAnimationId = null;
|
|
29
|
+
transformAnimationId = null;
|
|
30
|
+
visibilityDebounceTimeoutId = null;
|
|
31
|
+
el = inject((ElementRef));
|
|
32
|
+
renderer = inject(Renderer2);
|
|
33
|
+
zone = inject(NgZone);
|
|
34
|
+
hostElement;
|
|
35
|
+
cards = [];
|
|
36
|
+
constructor() {
|
|
37
|
+
// Effect remains the same
|
|
38
|
+
}
|
|
39
|
+
ngOnInit() {
|
|
40
|
+
this.hostElement = this.el.nativeElement;
|
|
41
|
+
this.renderer.setStyle(this.hostElement, 'cursor', 'grab');
|
|
42
|
+
this.hostElement.style.scrollBehavior = 'auto';
|
|
43
|
+
}
|
|
44
|
+
ngAfterContentInit() {
|
|
45
|
+
this.cards = Array.from(this.hostElement.querySelectorAll(this.cardSelector()));
|
|
46
|
+
// Initial state calculation after content is initialized and layout is stable
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
const actualInitialIndex = this.findCurrentCenterIndex();
|
|
49
|
+
this.emitActiveIndex(actualInitialIndex);
|
|
50
|
+
this.updateCardVisibilityClasses();
|
|
51
|
+
}, 0);
|
|
52
|
+
}
|
|
53
|
+
ngOnDestroy() {
|
|
54
|
+
this.clearSnapTimeout();
|
|
55
|
+
this.cancelScrollAnimation();
|
|
56
|
+
this.cancelTransformAnimation();
|
|
57
|
+
clearTimeout(this.visibilityDebounceTimeoutId);
|
|
58
|
+
}
|
|
59
|
+
onScroll(event) {
|
|
60
|
+
if (this.isDragging() || this.scrollAnimationId !== null || this.transformAnimationId !== null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (this.visibilityDebounceTimeoutId !== null) {
|
|
64
|
+
clearTimeout(this.visibilityDebounceTimeoutId);
|
|
65
|
+
}
|
|
66
|
+
this.visibilityDebounceTimeoutId = setTimeout(() => {
|
|
67
|
+
this.updateCardVisibilityClasses();
|
|
68
|
+
const currentIndex = this.findCurrentCenterIndex();
|
|
69
|
+
this.emitActiveIndex(currentIndex);
|
|
70
|
+
this.visibilityDebounceTimeoutId = null;
|
|
71
|
+
}, this.visibilityDebounceTime());
|
|
72
|
+
}
|
|
73
|
+
onMouseDown(event) {
|
|
74
|
+
clearTimeout(this.visibilityDebounceTimeoutId);
|
|
75
|
+
this.clearSnapTimeout();
|
|
76
|
+
this.cancelScrollAnimation();
|
|
77
|
+
this.cancelTransformAnimation();
|
|
78
|
+
if (this.currentTranslateX() !== 0) {
|
|
79
|
+
this.currentTranslateX.set(0);
|
|
80
|
+
this.renderer.setStyle(this.hostElement, 'transform', '');
|
|
81
|
+
}
|
|
82
|
+
this.hostElement.style.scrollBehavior = 'auto';
|
|
83
|
+
if (event.button !== 0)
|
|
84
|
+
return;
|
|
85
|
+
this.isDragging.set(true);
|
|
86
|
+
this.startX.set(event.pageX - this.hostElement.offsetLeft);
|
|
87
|
+
this.scrollLeftStart.set(this.hostElement.scrollLeft);
|
|
88
|
+
this.lastMoveX.set(event.pageX);
|
|
89
|
+
this.lastMoveTime.set(event.timeStamp);
|
|
90
|
+
this.currentVelocityX.set(0);
|
|
91
|
+
this.renderer.setStyle(this.hostElement, 'cursor', 'grabbing');
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
}
|
|
94
|
+
onMouseMove(event) {
|
|
95
|
+
if (!this.isDragging())
|
|
96
|
+
return;
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
const currentX = event.pageX;
|
|
99
|
+
const currentTime = event.timeStamp;
|
|
100
|
+
const lastMoveTime = this.lastMoveTime();
|
|
101
|
+
const lastMoveX = this.lastMoveX();
|
|
102
|
+
if (lastMoveTime !== null && lastMoveX !== null && currentTime > lastMoveTime) {
|
|
103
|
+
const deltaX = currentX - lastMoveX;
|
|
104
|
+
const deltaTime = currentTime - lastMoveTime;
|
|
105
|
+
if (deltaTime > 0) {
|
|
106
|
+
this.currentVelocityX.set(-deltaX / deltaTime);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
this.lastMoveX.set(currentX);
|
|
110
|
+
this.lastMoveTime.set(currentTime);
|
|
111
|
+
const dragDeltaX = currentX - (this.startX() + this.hostElement.offsetLeft);
|
|
112
|
+
const intendedScrollLeft = this.scrollLeftStart() - dragDeltaX;
|
|
113
|
+
const maxScrollLeft = this.hostElement.scrollWidth - this.hostElement.clientWidth;
|
|
114
|
+
let targetScrollLeft = intendedScrollLeft;
|
|
115
|
+
let translateX = 0;
|
|
116
|
+
if (intendedScrollLeft < 0) {
|
|
117
|
+
targetScrollLeft = 0;
|
|
118
|
+
const overpull = -intendedScrollLeft;
|
|
119
|
+
translateX = Math.min(overpull * this.resistanceFactor(), this.hostElement.clientWidth * 0.4);
|
|
120
|
+
}
|
|
121
|
+
else if (intendedScrollLeft > maxScrollLeft) {
|
|
122
|
+
targetScrollLeft = maxScrollLeft;
|
|
123
|
+
const overpull = intendedScrollLeft - maxScrollLeft;
|
|
124
|
+
translateX = -Math.min(overpull * this.resistanceFactor(), this.hostElement.clientWidth * 0.4);
|
|
125
|
+
}
|
|
126
|
+
if (this.hostElement.scrollLeft !== targetScrollLeft) {
|
|
127
|
+
this.hostElement.scrollLeft = targetScrollLeft;
|
|
128
|
+
}
|
|
129
|
+
if (this.currentTranslateX() !== translateX) {
|
|
130
|
+
this.currentTranslateX.set(translateX);
|
|
131
|
+
if (Math.abs(translateX) > 0.1) {
|
|
132
|
+
this.renderer.setStyle(this.hostElement, 'transform', `translateX(${translateX}px)`);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.currentTranslateX.set(0);
|
|
136
|
+
this.renderer.setStyle(this.hostElement, 'transform', '');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
onMouseUpOrLeave(event) {
|
|
141
|
+
if (!this.isDragging())
|
|
142
|
+
return;
|
|
143
|
+
this.stopDragging();
|
|
144
|
+
}
|
|
145
|
+
onMouseLeaveElement(event) {
|
|
146
|
+
if (!this.isDragging()) {
|
|
147
|
+
this.renderer.setStyle(this.hostElement, 'cursor', 'grab');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
stopDragging() {
|
|
151
|
+
if (!this.isDragging())
|
|
152
|
+
return;
|
|
153
|
+
this.isDragging.set(false);
|
|
154
|
+
this.renderer.setStyle(this.hostElement, 'cursor', 'grab');
|
|
155
|
+
this.clearSnapTimeout();
|
|
156
|
+
const wasPulled = Math.abs(this.currentTranslateX()) > 0.1;
|
|
157
|
+
if (wasPulled) {
|
|
158
|
+
this.snapTimeoutId = setTimeout(() => {
|
|
159
|
+
this.animateTransformReset();
|
|
160
|
+
this.snapTimeoutId = null;
|
|
161
|
+
}, this.snapDebounceTime() / 2);
|
|
162
|
+
}
|
|
163
|
+
else if (this.snapToCenter()) {
|
|
164
|
+
this.snapTimeoutId = setTimeout(() => {
|
|
165
|
+
this.initiateSnap();
|
|
166
|
+
this.snapTimeoutId = null;
|
|
167
|
+
}, this.snapDebounceTime());
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
this.updateCardVisibilityClasses();
|
|
171
|
+
const currentIndex = this.findCurrentCenterIndex();
|
|
172
|
+
this.emitActiveIndex(currentIndex);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
initiateSnap() {
|
|
176
|
+
this.cards = Array.from(this.hostElement.querySelectorAll(this.cardSelector()));
|
|
177
|
+
if (!this.cards.length)
|
|
178
|
+
return;
|
|
179
|
+
let targetCardIndex = -1;
|
|
180
|
+
const currentScroll = this.hostElement.scrollLeft;
|
|
181
|
+
const containerCenter = currentScroll + this.hostElement.clientWidth / 2;
|
|
182
|
+
let currentNearestCardIndex = this.findNearestCardIndex(this.cards, containerCenter);
|
|
183
|
+
if (currentNearestCardIndex < 0)
|
|
184
|
+
return;
|
|
185
|
+
const absVelocity = Math.abs(this.currentVelocityX());
|
|
186
|
+
const threshold = this.velocityThreshold();
|
|
187
|
+
if (absVelocity > threshold) {
|
|
188
|
+
if (this.currentVelocityX() < 0) {
|
|
189
|
+
targetCardIndex = currentNearestCardIndex - 1;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
targetCardIndex = currentNearestCardIndex + 1;
|
|
193
|
+
}
|
|
194
|
+
targetCardIndex = Math.max(0, Math.min(targetCardIndex, this.cards.length - 1));
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
targetCardIndex = currentNearestCardIndex;
|
|
198
|
+
}
|
|
199
|
+
if (targetCardIndex >= 0 && targetCardIndex < this.cards.length) {
|
|
200
|
+
this.scrollToCard(targetCardIndex, false);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
this.updateCardVisibilityClasses();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
scrollToCard(index, immediate = false) {
|
|
207
|
+
if (index < 0 || index >= this.cards.length) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const targetCard = this.cards[index];
|
|
211
|
+
if (!targetCard)
|
|
212
|
+
return;
|
|
213
|
+
const container = this.hostElement;
|
|
214
|
+
const containerWidth = container.clientWidth;
|
|
215
|
+
const targetCardLeft = targetCard.offsetLeft;
|
|
216
|
+
const targetCardWidth = targetCard.offsetWidth;
|
|
217
|
+
let targetScrollLeft = targetCardLeft + targetCardWidth / 2 - containerWidth / 2;
|
|
218
|
+
const maxScrollLeft = container.scrollWidth - containerWidth;
|
|
219
|
+
targetScrollLeft = Math.max(0, Math.min(targetScrollLeft, maxScrollLeft));
|
|
220
|
+
this.cancelScrollAnimation();
|
|
221
|
+
if (immediate) {
|
|
222
|
+
container.scrollLeft = targetScrollLeft;
|
|
223
|
+
this.updateCardVisibilityClasses();
|
|
224
|
+
this.emitActiveIndex(index);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
this.animateScroll(targetScrollLeft);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
findNearestCardIndex(cards, position) {
|
|
231
|
+
let nearestIndex = -1;
|
|
232
|
+
let minDistance = Infinity;
|
|
233
|
+
cards.forEach((card, index) => {
|
|
234
|
+
if (card instanceof HTMLElement) {
|
|
235
|
+
const cardLeft = card.offsetLeft;
|
|
236
|
+
const cardWidth = card.offsetWidth;
|
|
237
|
+
const cardCenter = cardLeft + cardWidth / 2;
|
|
238
|
+
const distance = Math.abs(cardCenter - position);
|
|
239
|
+
if (distance < minDistance) {
|
|
240
|
+
minDistance = distance;
|
|
241
|
+
nearestIndex = index;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
return nearestIndex;
|
|
246
|
+
}
|
|
247
|
+
animateTransformReset() {
|
|
248
|
+
this.cancelTransformAnimation();
|
|
249
|
+
const startTranslateX = this.currentTranslateX();
|
|
250
|
+
const distance = 0 - startTranslateX;
|
|
251
|
+
if (Math.abs(distance) < 1) {
|
|
252
|
+
if (startTranslateX !== 0) {
|
|
253
|
+
this.currentTranslateX.set(0);
|
|
254
|
+
this.renderer.setStyle(this.hostElement, 'transform', '');
|
|
255
|
+
const finalIndex = this.findCurrentCenterIndex();
|
|
256
|
+
this.emitActiveIndex(finalIndex);
|
|
257
|
+
this.updateCardVisibilityClasses();
|
|
258
|
+
}
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const duration = this.snapDuration();
|
|
262
|
+
let startTime = null;
|
|
263
|
+
const step = (timestamp) => {
|
|
264
|
+
if (startTime === null)
|
|
265
|
+
startTime = timestamp;
|
|
266
|
+
const elapsed = timestamp - startTime;
|
|
267
|
+
const progress = Math.min(1, elapsed / duration);
|
|
268
|
+
const easedProgress = easeOutQuad(progress);
|
|
269
|
+
const newTranslateX = startTranslateX + distance * easedProgress;
|
|
270
|
+
this.currentTranslateX.set(newTranslateX);
|
|
271
|
+
this.renderer.setStyle(this.hostElement, 'transform', `translateX(${newTranslateX}px)`);
|
|
272
|
+
if (progress < 1) {
|
|
273
|
+
this.transformAnimationId = requestAnimationFrame(step);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
this.currentTranslateX.set(0);
|
|
277
|
+
this.renderer.setStyle(this.hostElement, 'transform', '');
|
|
278
|
+
this.transformAnimationId = null;
|
|
279
|
+
const finalIndex = this.findCurrentCenterIndex();
|
|
280
|
+
this.emitActiveIndex(finalIndex);
|
|
281
|
+
this.updateCardVisibilityClasses();
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
this.zone.runOutsideAngular(() => {
|
|
285
|
+
this.transformAnimationId = requestAnimationFrame(step);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
animateScroll(targetScrollLeft) {
|
|
289
|
+
this.cancelScrollAnimation();
|
|
290
|
+
const container = this.hostElement;
|
|
291
|
+
const startScrollLeft = container.scrollLeft;
|
|
292
|
+
const distance = targetScrollLeft - startScrollLeft;
|
|
293
|
+
if (Math.abs(distance) < 1) {
|
|
294
|
+
const finalIndex = this.findCurrentCenterIndex();
|
|
295
|
+
this.emitActiveIndex(finalIndex);
|
|
296
|
+
this.updateCardVisibilityClasses();
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const duration = this.snapDuration();
|
|
300
|
+
let startTime = null;
|
|
301
|
+
const step = (timestamp) => {
|
|
302
|
+
if (startTime === null)
|
|
303
|
+
startTime = timestamp;
|
|
304
|
+
const elapsed = timestamp - startTime;
|
|
305
|
+
const progress = Math.min(1, elapsed / duration);
|
|
306
|
+
const easedProgress = easeOutQuad(progress);
|
|
307
|
+
container.scrollLeft = startScrollLeft + distance * easedProgress;
|
|
308
|
+
if (progress < 1) {
|
|
309
|
+
this.scrollAnimationId = requestAnimationFrame(step);
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
container.scrollLeft = targetScrollLeft;
|
|
313
|
+
this.scrollAnimationId = null;
|
|
314
|
+
const finalIndex = this.findCurrentCenterIndex();
|
|
315
|
+
this.emitActiveIndex(finalIndex);
|
|
316
|
+
this.updateCardVisibilityClasses();
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
this.zone.runOutsideAngular(() => {
|
|
320
|
+
this.scrollAnimationId = requestAnimationFrame(step);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
findCurrentCenterIndex() {
|
|
324
|
+
this.cards = Array.from(this.hostElement.querySelectorAll(this.cardSelector()));
|
|
325
|
+
if (!this.cards.length)
|
|
326
|
+
return -1;
|
|
327
|
+
const currentScroll = this.hostElement.scrollLeft;
|
|
328
|
+
const containerCenter = currentScroll + this.hostElement.clientWidth / 2;
|
|
329
|
+
return this.findNearestCardIndex(this.cards, containerCenter);
|
|
330
|
+
}
|
|
331
|
+
emitActiveIndex(index) {
|
|
332
|
+
if (index >= 0 && index !== this.lastEmittedIndex()) {
|
|
333
|
+
this.lastEmittedIndex.set(index);
|
|
334
|
+
this.zone.run(() => {
|
|
335
|
+
this.indexChange.emit(index);
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
updateCardVisibilityClasses() {
|
|
340
|
+
this.cards = Array.from(this.hostElement.querySelectorAll(this.cardSelector()));
|
|
341
|
+
if (!this.cards.length || !this.hostElement.clientWidth)
|
|
342
|
+
return;
|
|
343
|
+
const viewportStart = this.hostElement.scrollLeft;
|
|
344
|
+
const viewportWidth = this.hostElement.clientWidth;
|
|
345
|
+
const viewportEnd = viewportStart + viewportWidth;
|
|
346
|
+
const tolerance = 1;
|
|
347
|
+
this.cards.forEach(card => {
|
|
348
|
+
if (card instanceof HTMLElement) {
|
|
349
|
+
const cardStart = card.offsetLeft;
|
|
350
|
+
const cardEnd = cardStart + card.offsetWidth;
|
|
351
|
+
const isSpanned = cardStart >= viewportStart - tolerance && cardEnd <= viewportEnd + tolerance;
|
|
352
|
+
const isInView = cardEnd > viewportStart + tolerance && cardStart < viewportEnd - tolerance;
|
|
353
|
+
if (isSpanned) {
|
|
354
|
+
this.renderer.addClass(card, 'is-spanned');
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
this.renderer.removeClass(card, 'is-spanned');
|
|
358
|
+
}
|
|
359
|
+
if (isInView) {
|
|
360
|
+
this.renderer.addClass(card, 'is-in-view');
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
this.renderer.removeClass(card, 'is-in-view');
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
cancelScrollAnimation() {
|
|
369
|
+
if (this.scrollAnimationId !== null) {
|
|
370
|
+
cancelAnimationFrame(this.scrollAnimationId);
|
|
371
|
+
this.scrollAnimationId = null;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
cancelTransformAnimation() {
|
|
375
|
+
if (this.transformAnimationId !== null) {
|
|
376
|
+
cancelAnimationFrame(this.transformAnimationId);
|
|
377
|
+
this.transformAnimationId = null;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
clearSnapTimeout() {
|
|
381
|
+
if (this.snapTimeoutId !== null) {
|
|
382
|
+
clearTimeout(this.snapTimeoutId);
|
|
383
|
+
this.snapTimeoutId = null;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: DraggableCarouselDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
387
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.10", type: DraggableCarouselDirective, isStandalone: true, selector: "[emrDraggableCarousel]", inputs: { cardSelector: { classPropertyName: "cardSelector", publicName: "cardSelector", isSignal: true, isRequired: false, transformFunction: null }, snapToCenter: { classPropertyName: "snapToCenter", publicName: "snapToCenter", isSignal: true, isRequired: false, transformFunction: null }, snapDebounceTime: { classPropertyName: "snapDebounceTime", publicName: "snapDebounceTime", isSignal: true, isRequired: false, transformFunction: null }, snapDuration: { classPropertyName: "snapDuration", publicName: "snapDuration", isSignal: true, isRequired: false, transformFunction: null }, resistanceFactor: { classPropertyName: "resistanceFactor", publicName: "resistanceFactor", isSignal: true, isRequired: false, transformFunction: null }, velocityThreshold: { classPropertyName: "velocityThreshold", publicName: "velocityThreshold", isSignal: true, isRequired: false, transformFunction: null }, visibilityDebounceTime: { classPropertyName: "visibilityDebounceTime", publicName: "visibilityDebounceTime", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { indexChange: "indexChange" }, host: { listeners: { "scroll": "onScroll($event)", "mousedown": "onMouseDown($event)", "mouseleave": "onMouseLeaveElement($event)", "document:mousemove": "onMouseMove($event)", "document:mouseup": "onMouseUpOrLeave($event)", "document:mouseleave": "onMouseUpOrLeave($event)" }, properties: { "class.dragging-active": "isDragging()" } }, ngImport: i0 });
|
|
388
|
+
}
|
|
389
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: DraggableCarouselDirective, decorators: [{
|
|
390
|
+
type: Directive,
|
|
391
|
+
args: [{
|
|
392
|
+
selector: '[emrDraggableCarousel]',
|
|
393
|
+
standalone: true,
|
|
394
|
+
host: {
|
|
395
|
+
'(scroll)': 'onScroll($event)',
|
|
396
|
+
'(mousedown)': 'onMouseDown($event)',
|
|
397
|
+
'(mouseleave)': 'onMouseLeaveElement($event)',
|
|
398
|
+
'(document:mousemove)': 'onMouseMove($event)',
|
|
399
|
+
'(document:mouseup)': 'onMouseUpOrLeave($event)',
|
|
400
|
+
'(document:mouseleave)': 'onMouseUpOrLeave($event)',
|
|
401
|
+
'[class.dragging-active]': 'isDragging()'
|
|
402
|
+
}
|
|
403
|
+
}]
|
|
404
|
+
}], ctorParameters: () => [], propDecorators: { cardSelector: [{ type: i0.Input, args: [{ isSignal: true, alias: "cardSelector", required: false }] }], snapToCenter: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToCenter", required: false }] }], snapDebounceTime: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapDebounceTime", required: false }] }], snapDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapDuration", required: false }] }], resistanceFactor: [{ type: i0.Input, args: [{ isSignal: true, alias: "resistanceFactor", required: false }] }], velocityThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "velocityThreshold", required: false }] }], visibilityDebounceTime: [{ type: i0.Input, args: [{ isSignal: true, alias: "visibilityDebounceTime", required: false }] }], indexChange: [{ type: i0.Output, args: ["indexChange"] }] } });
|
|
405
|
+
|
|
406
|
+
class CarouselComponent {
|
|
407
|
+
_content = viewChild.required('content');
|
|
408
|
+
_cards = contentChildren(CAROUSEL_CARD, ...(ngDevMode ? [{ debugName: "_cards" }] : []));
|
|
409
|
+
fade = input(false, ...(ngDevMode ? [{ debugName: "fade", transform: booleanAttribute }] : [{
|
|
410
|
+
transform: booleanAttribute
|
|
411
|
+
}]));
|
|
412
|
+
snapToCenter = input(true, ...(ngDevMode ? [{ debugName: "snapToCenter" }] : []));
|
|
413
|
+
snapDebounceTime = input(50, ...(ngDevMode ? [{ debugName: "snapDebounceTime" }] : []));
|
|
414
|
+
snapDuration = input(300, ...(ngDevMode ? [{ debugName: "snapDuration" }] : []));
|
|
415
|
+
resistanceFactor = input(0.5, ...(ngDevMode ? [{ debugName: "resistanceFactor" }] : []));
|
|
416
|
+
velocityThreshold = input(0.5, ...(ngDevMode ? [{ debugName: "velocityThreshold" }] : []));
|
|
417
|
+
visibilityDebounceTime = input(100, ...(ngDevMode ? [{ debugName: "visibilityDebounceTime" }] : []));
|
|
418
|
+
indexChange = output();
|
|
419
|
+
_index = signal(0, ...(ngDevMode ? [{ debugName: "_index" }] : []));
|
|
420
|
+
get api() {
|
|
421
|
+
return {
|
|
422
|
+
isNextDisabled: () => this._isNextDisabled,
|
|
423
|
+
isPreviousDisabled: () => this._isPreviousDisabled,
|
|
424
|
+
previous: () => this._previous(),
|
|
425
|
+
next: () => this._next(),
|
|
426
|
+
selectedIndex: () => this._index()
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
onIndexChanged(index) {
|
|
430
|
+
if (this._index() === index) {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
this._index.set(index);
|
|
434
|
+
this.indexChange.emit(index);
|
|
435
|
+
}
|
|
436
|
+
_previous() {
|
|
437
|
+
const contentElement = this._content()?.nativeElement;
|
|
438
|
+
for (let index = this._cards().length - 1; index >= 0; index--) {
|
|
439
|
+
if (index >= this._index()) {
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
const card = this._cards().at(index);
|
|
443
|
+
if (!this._visibleInParentViewport(contentElement, card.element)) {
|
|
444
|
+
this._scrollToCard(card);
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
_next() {
|
|
450
|
+
const contentElement = this._content().nativeElement;
|
|
451
|
+
const notVisibleCard = this._cards().find((card, index) => !this._visibleInParentViewport(contentElement, card.element) && index > this._index());
|
|
452
|
+
if (notVisibleCard) {
|
|
453
|
+
this._scrollToCard(notVisibleCard);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
_scrollToCard(notVisibleCard) {
|
|
457
|
+
this._index.set(this._cards().findIndex(card => card === notVisibleCard));
|
|
458
|
+
this.indexChange.emit(this._index());
|
|
459
|
+
notVisibleCard.element.scrollIntoView({
|
|
460
|
+
block: 'nearest',
|
|
461
|
+
behavior: 'smooth',
|
|
462
|
+
inline: 'center'
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
_visibleInParentViewport = (parent, el) => {
|
|
466
|
+
const parentRect = parent.getBoundingClientRect();
|
|
467
|
+
const elementRect = el.getBoundingClientRect();
|
|
468
|
+
return (elementRect.right <= parentRect.right &&
|
|
469
|
+
elementRect.left >= parentRect.left);
|
|
470
|
+
};
|
|
471
|
+
get _isPreviousDisabled() {
|
|
472
|
+
return this._index() === 0;
|
|
473
|
+
}
|
|
474
|
+
get _isNextDisabled() {
|
|
475
|
+
return this._index() === this._cards().length - 1;
|
|
476
|
+
}
|
|
477
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: CarouselComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
478
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.3.10", type: CarouselComponent, isStandalone: true, selector: "emr-carousel", inputs: { fade: { classPropertyName: "fade", publicName: "fade", isSignal: true, isRequired: false, transformFunction: null }, snapToCenter: { classPropertyName: "snapToCenter", publicName: "snapToCenter", isSignal: true, isRequired: false, transformFunction: null }, snapDebounceTime: { classPropertyName: "snapDebounceTime", publicName: "snapDebounceTime", isSignal: true, isRequired: false, transformFunction: null }, snapDuration: { classPropertyName: "snapDuration", publicName: "snapDuration", isSignal: true, isRequired: false, transformFunction: null }, resistanceFactor: { classPropertyName: "resistanceFactor", publicName: "resistanceFactor", isSignal: true, isRequired: false, transformFunction: null }, velocityThreshold: { classPropertyName: "velocityThreshold", publicName: "velocityThreshold", isSignal: true, isRequired: false, transformFunction: null }, visibilityDebounceTime: { classPropertyName: "visibilityDebounceTime", publicName: "visibilityDebounceTime", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { indexChange: "indexChange" }, host: { properties: { "class.fade": "fade()" }, classAttribute: "emr-carousel" }, providers: [
|
|
479
|
+
{
|
|
480
|
+
provide: CAROUSEL,
|
|
481
|
+
useExisting: CarouselComponent
|
|
482
|
+
}
|
|
483
|
+
], queries: [{ propertyName: "_cards", predicate: CAROUSEL_CARD, isSignal: true }], viewQueries: [{ propertyName: "_content", first: true, predicate: ["content"], descendants: true, isSignal: true }], exportAs: ["emrCarousel"], ngImport: i0, template: "<div #content class=\"content\"\r\n emrDraggableCarousel\r\n [snapToCenter]=\"snapToCenter()\"\r\n [snapDebounceTime]=\"snapDebounceTime()\"\r\n [snapDuration]=\"snapDuration()\"\r\n [resistanceFactor]=\"resistanceFactor()\"\r\n [velocityThreshold]=\"velocityThreshold()\"\r\n [visibilityDebounceTime]=\"visibilityDebounceTime()\"\r\n (indexChange)=\"onIndexChanged($event)\">\r\n <ng-content select=\"emr-carousel-card,[emr-carousel-card]\"></ng-content>\r\n</div>\r\n<div class=\"controls\">\r\n <ng-content select=\"[emrCarouselControls]\"></ng-content>\r\n</div>\r\n", styles: [":host{--emr-carousel-gap: calc(var(--spacing, .25rem) * 8);display:block;position:relative}:host .content{display:flex;overflow:hidden;gap:var(--emr-carousel-gap)}:host .controls{margin-top:calc(var(--spacing, .25rem) * 4);gap:calc(var(--spacing, .25rem) * 3)}:host .controls:empty{display:none}\n/*! tailwindcss v4.1.14 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "directive", type: DraggableCarouselDirective, selector: "[emrDraggableCarousel]", inputs: ["cardSelector", "snapToCenter", "snapDebounceTime", "snapDuration", "resistanceFactor", "velocityThreshold", "visibilityDebounceTime"], outputs: ["indexChange"] }] });
|
|
484
|
+
}
|
|
485
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: CarouselComponent, decorators: [{
|
|
486
|
+
type: Component,
|
|
487
|
+
args: [{ selector: 'emr-carousel', exportAs: 'emrCarousel', providers: [
|
|
488
|
+
{
|
|
489
|
+
provide: CAROUSEL,
|
|
490
|
+
useExisting: CarouselComponent
|
|
491
|
+
}
|
|
492
|
+
], hostDirectives: [], imports: [
|
|
493
|
+
DraggableCarouselDirective
|
|
494
|
+
], host: {
|
|
495
|
+
'class': 'emr-carousel',
|
|
496
|
+
'[class.fade]': 'fade()',
|
|
497
|
+
}, template: "<div #content class=\"content\"\r\n emrDraggableCarousel\r\n [snapToCenter]=\"snapToCenter()\"\r\n [snapDebounceTime]=\"snapDebounceTime()\"\r\n [snapDuration]=\"snapDuration()\"\r\n [resistanceFactor]=\"resistanceFactor()\"\r\n [velocityThreshold]=\"velocityThreshold()\"\r\n [visibilityDebounceTime]=\"visibilityDebounceTime()\"\r\n (indexChange)=\"onIndexChanged($event)\">\r\n <ng-content select=\"emr-carousel-card,[emr-carousel-card]\"></ng-content>\r\n</div>\r\n<div class=\"controls\">\r\n <ng-content select=\"[emrCarouselControls]\"></ng-content>\r\n</div>\r\n", styles: [":host{--emr-carousel-gap: calc(var(--spacing, .25rem) * 8);display:block;position:relative}:host .content{display:flex;overflow:hidden;gap:var(--emr-carousel-gap)}:host .controls{margin-top:calc(var(--spacing, .25rem) * 4);gap:calc(var(--spacing, .25rem) * 3)}:host .controls:empty{display:none}\n/*! tailwindcss v4.1.14 | MIT License | https://tailwindcss.com */\n"] }]
|
|
498
|
+
}], propDecorators: { _content: [{ type: i0.ViewChild, args: ['content', { isSignal: true }] }], _cards: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CAROUSEL_CARD), { isSignal: true }] }], fade: [{ type: i0.Input, args: [{ isSignal: true, alias: "fade", required: false }] }], snapToCenter: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToCenter", required: false }] }], snapDebounceTime: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapDebounceTime", required: false }] }], snapDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapDuration", required: false }] }], resistanceFactor: [{ type: i0.Input, args: [{ isSignal: true, alias: "resistanceFactor", required: false }] }], velocityThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "velocityThreshold", required: false }] }], visibilityDebounceTime: [{ type: i0.Input, args: [{ isSignal: true, alias: "visibilityDebounceTime", required: false }] }], indexChange: [{ type: i0.Output, args: ["indexChange"] }] } });
|
|
499
|
+
|
|
500
|
+
class CarouselCardComponent {
|
|
501
|
+
_elementRef = inject(ElementRef);
|
|
502
|
+
get element() {
|
|
503
|
+
return this._elementRef.nativeElement;
|
|
504
|
+
}
|
|
505
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: CarouselCardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
506
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.10", type: CarouselCardComponent, isStandalone: true, selector: "emr-carousel-card,[emr-carousel-card]", host: { classAttribute: "emr-carousel-card" }, providers: [
|
|
507
|
+
{
|
|
508
|
+
provide: CAROUSEL_CARD,
|
|
509
|
+
useExisting: CarouselCardComponent
|
|
510
|
+
}
|
|
511
|
+
], exportAs: ["emrCarouselCard"], ngImport: i0, template: "<ng-content></ng-content>\r\n", styles: [":host{display:block;scroll-padding-inline:100px;flex:none}:host-context(.emr-carousel.fade){animation:emr-carousel-fade;animation-fill-mode:both;animation-timing-function:linear;animation-timeline:view(inline)}@keyframes emr-carousel-fade{0%,to{opacity:.3}50%{opacity:1}}\n/*! tailwindcss v4.1.14 | MIT License | https://tailwindcss.com */\n"] });
|
|
512
|
+
}
|
|
513
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: CarouselCardComponent, decorators: [{
|
|
514
|
+
type: Component,
|
|
515
|
+
args: [{ selector: 'emr-carousel-card,[emr-carousel-card]', exportAs: 'emrCarouselCard', imports: [], providers: [
|
|
516
|
+
{
|
|
517
|
+
provide: CAROUSEL_CARD,
|
|
518
|
+
useExisting: CarouselCardComponent
|
|
519
|
+
}
|
|
520
|
+
], host: {
|
|
521
|
+
'class': 'emr-carousel-card',
|
|
522
|
+
}, template: "<ng-content></ng-content>\r\n", styles: [":host{display:block;scroll-padding-inline:100px;flex:none}:host-context(.emr-carousel.fade){animation:emr-carousel-fade;animation-fill-mode:both;animation-timing-function:linear;animation-timeline:view(inline)}@keyframes emr-carousel-fade{0%,to{opacity:.3}50%{opacity:1}}\n/*! tailwindcss v4.1.14 | MIT License | https://tailwindcss.com */\n"] }]
|
|
523
|
+
}] });
|
|
524
|
+
|
|
525
|
+
class CarouselControlsDirective {
|
|
526
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: CarouselControlsDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
527
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.10", type: CarouselControlsDirective, isStandalone: true, selector: "[emrCarouselControls]", host: { classAttribute: "emr-carousel-controls" }, ngImport: i0 });
|
|
528
|
+
}
|
|
529
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: CarouselControlsDirective, decorators: [{
|
|
530
|
+
type: Directive,
|
|
531
|
+
args: [{
|
|
532
|
+
selector: '[emrCarouselControls]',
|
|
533
|
+
standalone: true,
|
|
534
|
+
host: {
|
|
535
|
+
'class': 'emr-carousel-controls',
|
|
536
|
+
}
|
|
537
|
+
}]
|
|
538
|
+
}] });
|
|
539
|
+
|
|
540
|
+
class CarouselPreviousDirective {
|
|
541
|
+
_carousel = inject(CAROUSEL, {
|
|
542
|
+
optional: true
|
|
543
|
+
});
|
|
544
|
+
carousel = input(null, ...(ngDevMode ? [{ debugName: "carousel" }] : []));
|
|
545
|
+
ngOnInit() {
|
|
546
|
+
if (this.carousel() && !this._carousel) {
|
|
547
|
+
this._carousel = this.carousel();
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
_handleClick() {
|
|
551
|
+
this._carousel?.api.previous();
|
|
552
|
+
}
|
|
553
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: CarouselPreviousDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
554
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.10", type: CarouselPreviousDirective, isStandalone: true, selector: "[emrCarouselPrevious]", inputs: { carousel: { classPropertyName: "carousel", publicName: "carousel", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "_handleClick()" }, properties: { "attr.disabled": "_carousel?.api?.isPreviousDisabled() ? true : null" }, classAttribute: "emr-carousel-previous" }, exportAs: ["emrCarouselPrevious"], ngImport: i0 });
|
|
555
|
+
}
|
|
556
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: CarouselPreviousDirective, decorators: [{
|
|
557
|
+
type: Directive,
|
|
558
|
+
args: [{
|
|
559
|
+
selector: '[emrCarouselPrevious]',
|
|
560
|
+
exportAs: 'emrCarouselPrevious',
|
|
561
|
+
standalone: true,
|
|
562
|
+
host: {
|
|
563
|
+
'class': 'emr-carousel-previous',
|
|
564
|
+
'[attr.disabled]': '_carousel?.api?.isPreviousDisabled() ? true : null',
|
|
565
|
+
'(click)': '_handleClick()'
|
|
566
|
+
}
|
|
567
|
+
}]
|
|
568
|
+
}], propDecorators: { carousel: [{ type: i0.Input, args: [{ isSignal: true, alias: "carousel", required: false }] }] } });
|
|
569
|
+
|
|
570
|
+
class CarouselNextDirective {
|
|
571
|
+
_carousel = inject(CAROUSEL, {
|
|
572
|
+
optional: true
|
|
573
|
+
});
|
|
574
|
+
carousel = input(null, ...(ngDevMode ? [{ debugName: "carousel" }] : []));
|
|
575
|
+
ngOnInit() {
|
|
576
|
+
if (this.carousel() && !this._carousel) {
|
|
577
|
+
this._carousel = this.carousel();
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
_handleClick() {
|
|
581
|
+
this._carousel?.api.next();
|
|
582
|
+
}
|
|
583
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: CarouselNextDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
584
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.10", type: CarouselNextDirective, isStandalone: true, selector: "[emrCarouselNext]", inputs: { carousel: { classPropertyName: "carousel", publicName: "carousel", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "_handleClick()" }, properties: { "attr.disabled": "_carousel?.api?.isNextDisabled() ? true : null" }, classAttribute: "emr-carousel-next" }, exportAs: ["emrCarouselNext"], ngImport: i0 });
|
|
585
|
+
}
|
|
586
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: CarouselNextDirective, decorators: [{
|
|
587
|
+
type: Directive,
|
|
588
|
+
args: [{
|
|
589
|
+
selector: '[emrCarouselNext]',
|
|
590
|
+
exportAs: 'emrCarouselNext',
|
|
591
|
+
standalone: true,
|
|
592
|
+
host: {
|
|
593
|
+
'class': 'emr-carousel-next',
|
|
594
|
+
'[attr.disabled]': '_carousel?.api?.isNextDisabled() ? true : null',
|
|
595
|
+
'(click)': '_handleClick()'
|
|
596
|
+
}
|
|
597
|
+
}]
|
|
598
|
+
}], propDecorators: { carousel: [{ type: i0.Input, args: [{ isSignal: true, alias: "carousel", required: false }] }] } });
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Generated bundle index. Do not edit.
|
|
602
|
+
*/
|
|
603
|
+
|
|
604
|
+
export { CAROUSEL, CAROUSEL_CARD, CarouselCardComponent, CarouselComponent, CarouselControlsDirective, CarouselNextDirective, CarouselPreviousDirective };
|
|
605
|
+
//# sourceMappingURL=elementar-rt-components-carousel.mjs.map
|