1 | import * as i0 from '@angular/core';
|
---|
2 | import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ViewChild, ContentChild, ContentChildren, NgModule } from '@angular/core';
|
---|
3 | import { Header, Footer, PrimeTemplate, SharedModule } from 'primeng/api';
|
---|
4 | import * as i2 from 'primeng/ripple';
|
---|
5 | import { RippleModule } from 'primeng/ripple';
|
---|
6 | import * as i1 from '@angular/common';
|
---|
7 | import { CommonModule } from '@angular/common';
|
---|
8 | import { UniqueComponentId } from 'primeng/utils';
|
---|
9 |
|
---|
10 | class Carousel {
|
---|
11 | constructor(el, zone, cd) {
|
---|
12 | this.el = el;
|
---|
13 | this.zone = zone;
|
---|
14 | this.cd = cd;
|
---|
15 | this.orientation = "horizontal";
|
---|
16 | this.verticalViewPortHeight = "300px";
|
---|
17 | this.contentClass = "";
|
---|
18 | this.indicatorsContentClass = "";
|
---|
19 | this.indicatorStyleClass = "";
|
---|
20 | this.circular = false;
|
---|
21 | this.showIndicators = true;
|
---|
22 | this.showNavigators = true;
|
---|
23 | this.autoplayInterval = 0;
|
---|
24 | this.onPage = new EventEmitter();
|
---|
25 | this._numVisible = 1;
|
---|
26 | this._numScroll = 1;
|
---|
27 | this._oldNumScroll = 0;
|
---|
28 | this.prevState = {
|
---|
29 | numScroll: 0,
|
---|
30 | numVisible: 0,
|
---|
31 | value: []
|
---|
32 | };
|
---|
33 | this.defaultNumScroll = 1;
|
---|
34 | this.defaultNumVisible = 1;
|
---|
35 | this._page = 0;
|
---|
36 | this.isRemainingItemsAdded = false;
|
---|
37 | this.remainingItems = 0;
|
---|
38 | this.swipeThreshold = 20;
|
---|
39 | this.totalShiftedItems = this.page * this.numScroll * -1;
|
---|
40 | }
|
---|
41 | get page() {
|
---|
42 | return this._page;
|
---|
43 | }
|
---|
44 | set page(val) {
|
---|
45 | if (this.isCreated && val !== this._page) {
|
---|
46 | if (this.autoplayInterval) {
|
---|
47 | this.stopAutoplay();
|
---|
48 | this.allowAutoplay = false;
|
---|
49 | }
|
---|
50 | if (val > this._page && val <= (this.totalDots() - 1)) {
|
---|
51 | this.step(-1, val);
|
---|
52 | }
|
---|
53 | else if (val < this._page) {
|
---|
54 | this.step(1, val);
|
---|
55 | }
|
---|
56 | }
|
---|
57 | this._page = val;
|
---|
58 | }
|
---|
59 | get numVisible() {
|
---|
60 | return this._numVisible;
|
---|
61 | }
|
---|
62 | set numVisible(val) {
|
---|
63 | this._numVisible = val;
|
---|
64 | }
|
---|
65 | get numScroll() {
|
---|
66 | return this._numVisible;
|
---|
67 | }
|
---|
68 | set numScroll(val) {
|
---|
69 | this._numScroll = val;
|
---|
70 | }
|
---|
71 | get value() {
|
---|
72 | return this._value;
|
---|
73 | }
|
---|
74 | ;
|
---|
75 | set value(val) {
|
---|
76 | this._value = val;
|
---|
77 | }
|
---|
78 | ngOnChanges(simpleChange) {
|
---|
79 | if (simpleChange.value) {
|
---|
80 | if (this.circular && this._value) {
|
---|
81 | this.setCloneItems();
|
---|
82 | }
|
---|
83 | }
|
---|
84 | if (this.isCreated) {
|
---|
85 | if (simpleChange.numVisible) {
|
---|
86 | if (this.responsiveOptions) {
|
---|
87 | this.defaultNumVisible = this.numVisible;
|
---|
88 | }
|
---|
89 | if (this.isCircular()) {
|
---|
90 | this.setCloneItems();
|
---|
91 | }
|
---|
92 | this.createStyle();
|
---|
93 | this.calculatePosition();
|
---|
94 | }
|
---|
95 | if (simpleChange.numScroll) {
|
---|
96 | if (this.responsiveOptions) {
|
---|
97 | this.defaultNumScroll = this.numScroll;
|
---|
98 | }
|
---|
99 | }
|
---|
100 | }
|
---|
101 | }
|
---|
102 | ngAfterContentInit() {
|
---|
103 | this.id = UniqueComponentId();
|
---|
104 | this.allowAutoplay = !!this.autoplayInterval;
|
---|
105 | if (this.circular) {
|
---|
106 | this.setCloneItems();
|
---|
107 | }
|
---|
108 | if (this.responsiveOptions) {
|
---|
109 | this.defaultNumScroll = this._numScroll;
|
---|
110 | this.defaultNumVisible = this._numVisible;
|
---|
111 | }
|
---|
112 | this.createStyle();
|
---|
113 | this.calculatePosition();
|
---|
114 | if (this.responsiveOptions) {
|
---|
115 | this.bindDocumentListeners();
|
---|
116 | }
|
---|
117 | this.templates.forEach((item) => {
|
---|
118 | switch (item.getType()) {
|
---|
119 | case 'item':
|
---|
120 | this.itemTemplate = item.template;
|
---|
121 | break;
|
---|
122 | case 'header':
|
---|
123 | this.headerTemplate = item.template;
|
---|
124 | break;
|
---|
125 | case 'footer':
|
---|
126 | this.footerTemplate = item.template;
|
---|
127 | break;
|
---|
128 | default:
|
---|
129 | this.itemTemplate = item.template;
|
---|
130 | break;
|
---|
131 | }
|
---|
132 | });
|
---|
133 | }
|
---|
134 | ngAfterContentChecked() {
|
---|
135 | const isCircular = this.isCircular();
|
---|
136 | let totalShiftedItems = this.totalShiftedItems;
|
---|
137 | if (this.value && this.itemsContainer && (this.prevState.numScroll !== this._numScroll || this.prevState.numVisible !== this._numVisible || this.prevState.value.length !== this.value.length)) {
|
---|
138 | if (this.autoplayInterval) {
|
---|
139 | this.stopAutoplay();
|
---|
140 | }
|
---|
141 | this.remainingItems = (this.value.length - this._numVisible) % this._numScroll;
|
---|
142 | let page = this._page;
|
---|
143 | if (this.totalDots() !== 0 && page >= this.totalDots()) {
|
---|
144 | page = this.totalDots() - 1;
|
---|
145 | this._page = page;
|
---|
146 | this.onPage.emit({
|
---|
147 | page: this.page
|
---|
148 | });
|
---|
149 | }
|
---|
150 | totalShiftedItems = (page * this._numScroll) * -1;
|
---|
151 | if (isCircular) {
|
---|
152 | totalShiftedItems -= this._numVisible;
|
---|
153 | }
|
---|
154 | if (page === (this.totalDots() - 1) && this.remainingItems > 0) {
|
---|
155 | totalShiftedItems += (-1 * this.remainingItems) + this._numScroll;
|
---|
156 | this.isRemainingItemsAdded = true;
|
---|
157 | }
|
---|
158 | else {
|
---|
159 | this.isRemainingItemsAdded = false;
|
---|
160 | }
|
---|
161 | if (totalShiftedItems !== this.totalShiftedItems) {
|
---|
162 | this.totalShiftedItems = totalShiftedItems;
|
---|
163 | }
|
---|
164 | this._oldNumScroll = this._numScroll;
|
---|
165 | this.prevState.numScroll = this._numScroll;
|
---|
166 | this.prevState.numVisible = this._numVisible;
|
---|
167 | this.prevState.value = [...this._value];
|
---|
168 | if (this.totalDots() > 0 && this.itemsContainer.nativeElement) {
|
---|
169 | this.itemsContainer.nativeElement.style.transform = this.isVertical() ? `translate3d(0, ${totalShiftedItems * (100 / this._numVisible)}%, 0)` : `translate3d(${totalShiftedItems * (100 / this._numVisible)}%, 0, 0)`;
|
---|
170 | }
|
---|
171 | this.isCreated = true;
|
---|
172 | if (this.autoplayInterval && this.isAutoplay()) {
|
---|
173 | this.startAutoplay();
|
---|
174 | }
|
---|
175 | }
|
---|
176 | if (isCircular) {
|
---|
177 | if (this.page === 0) {
|
---|
178 | totalShiftedItems = -1 * this._numVisible;
|
---|
179 | }
|
---|
180 | else if (totalShiftedItems === 0) {
|
---|
181 | totalShiftedItems = -1 * this.value.length;
|
---|
182 | if (this.remainingItems > 0) {
|
---|
183 | this.isRemainingItemsAdded = true;
|
---|
184 | }
|
---|
185 | }
|
---|
186 | if (totalShiftedItems !== this.totalShiftedItems) {
|
---|
187 | this.totalShiftedItems = totalShiftedItems;
|
---|
188 | }
|
---|
189 | }
|
---|
190 | }
|
---|
191 | createStyle() {
|
---|
192 | if (!this.carouselStyle) {
|
---|
193 | this.carouselStyle = document.createElement('style');
|
---|
194 | this.carouselStyle.type = 'text/css';
|
---|
195 | document.body.appendChild(this.carouselStyle);
|
---|
196 | }
|
---|
197 | let innerHTML = `
|
---|
198 | #${this.id} .p-carousel-item {
|
---|
199 | flex: 1 0 ${(100 / this.numVisible)}%
|
---|
200 | }
|
---|
201 | `;
|
---|
202 | if (this.responsiveOptions) {
|
---|
203 | this.responsiveOptions.sort((data1, data2) => {
|
---|
204 | const value1 = data1.breakpoint;
|
---|
205 | const value2 = data2.breakpoint;
|
---|
206 | let result = null;
|
---|
207 | if (value1 == null && value2 != null)
|
---|
208 | result = -1;
|
---|
209 | else if (value1 != null && value2 == null)
|
---|
210 | result = 1;
|
---|
211 | else if (value1 == null && value2 == null)
|
---|
212 | result = 0;
|
---|
213 | else if (typeof value1 === 'string' && typeof value2 === 'string')
|
---|
214 | result = value1.localeCompare(value2, undefined, { numeric: true });
|
---|
215 | else
|
---|
216 | result = (value1 < value2) ? -1 : (value1 > value2) ? 1 : 0;
|
---|
217 | return -1 * result;
|
---|
218 | });
|
---|
219 | for (let i = 0; i < this.responsiveOptions.length; i++) {
|
---|
220 | let res = this.responsiveOptions[i];
|
---|
221 | innerHTML += `
|
---|
222 | @media screen and (max-width: ${res.breakpoint}) {
|
---|
223 | #${this.id} .p-carousel-item {
|
---|
224 | flex: 1 0 ${(100 / res.numVisible)}%
|
---|
225 | }
|
---|
226 | }
|
---|
227 | `;
|
---|
228 | }
|
---|
229 | }
|
---|
230 | this.carouselStyle.innerHTML = innerHTML;
|
---|
231 | }
|
---|
232 | calculatePosition() {
|
---|
233 | if (this.responsiveOptions) {
|
---|
234 | let windowWidth = window.innerWidth;
|
---|
235 | let matchedResponsiveData = {
|
---|
236 | numVisible: this.defaultNumVisible,
|
---|
237 | numScroll: this.defaultNumScroll
|
---|
238 | };
|
---|
239 | for (let i = 0; i < this.responsiveOptions.length; i++) {
|
---|
240 | let res = this.responsiveOptions[i];
|
---|
241 | if (parseInt(res.breakpoint, 10) >= windowWidth) {
|
---|
242 | matchedResponsiveData = res;
|
---|
243 | }
|
---|
244 | }
|
---|
245 | if (this._numScroll !== matchedResponsiveData.numScroll) {
|
---|
246 | let page = this._page;
|
---|
247 | page = Math.floor((page * this._numScroll) / matchedResponsiveData.numScroll);
|
---|
248 | let totalShiftedItems = (matchedResponsiveData.numScroll * this.page) * -1;
|
---|
249 | if (this.isCircular()) {
|
---|
250 | totalShiftedItems -= matchedResponsiveData.numVisible;
|
---|
251 | }
|
---|
252 | this.totalShiftedItems = totalShiftedItems;
|
---|
253 | this._numScroll = matchedResponsiveData.numScroll;
|
---|
254 | this._page = page;
|
---|
255 | this.onPage.emit({
|
---|
256 | page: this.page
|
---|
257 | });
|
---|
258 | }
|
---|
259 | if (this._numVisible !== matchedResponsiveData.numVisible) {
|
---|
260 | this._numVisible = matchedResponsiveData.numVisible;
|
---|
261 | this.setCloneItems();
|
---|
262 | }
|
---|
263 | this.cd.markForCheck();
|
---|
264 | }
|
---|
265 | }
|
---|
266 | setCloneItems() {
|
---|
267 | this.clonedItemsForStarting = [];
|
---|
268 | this.clonedItemsForFinishing = [];
|
---|
269 | if (this.isCircular()) {
|
---|
270 | this.clonedItemsForStarting.push(...this.value.slice(-1 * this._numVisible));
|
---|
271 | this.clonedItemsForFinishing.push(...this.value.slice(0, this._numVisible));
|
---|
272 | }
|
---|
273 | }
|
---|
274 | firstIndex() {
|
---|
275 | return this.isCircular() ? (-1 * (this.totalShiftedItems + this.numVisible)) : (this.totalShiftedItems * -1);
|
---|
276 | }
|
---|
277 | lastIndex() {
|
---|
278 | return this.firstIndex() + this.numVisible - 1;
|
---|
279 | }
|
---|
280 | totalDots() {
|
---|
281 | return this.value ? Math.ceil((this.value.length - this._numVisible) / this._numScroll) + 1 : 0;
|
---|
282 | }
|
---|
283 | totalDotsArray() {
|
---|
284 | const totalDots = this.totalDots();
|
---|
285 | return totalDots <= 0 ? [] : Array(totalDots).fill(0);
|
---|
286 | }
|
---|
287 | isVertical() {
|
---|
288 | return this.orientation === 'vertical';
|
---|
289 | }
|
---|
290 | isCircular() {
|
---|
291 | return this.circular && this.value && this.value.length >= this.numVisible;
|
---|
292 | }
|
---|
293 | isAutoplay() {
|
---|
294 | return this.autoplayInterval && this.allowAutoplay;
|
---|
295 | }
|
---|
296 | isForwardNavDisabled() {
|
---|
297 | return this.isEmpty() || (this._page >= (this.totalDots() - 1) && !this.isCircular());
|
---|
298 | }
|
---|
299 | isBackwardNavDisabled() {
|
---|
300 | return this.isEmpty() || (this._page <= 0 && !this.isCircular());
|
---|
301 | }
|
---|
302 | isEmpty() {
|
---|
303 | return !this.value || this.value.length === 0;
|
---|
304 | }
|
---|
305 | navForward(e, index) {
|
---|
306 | if (this.isCircular() || this._page < (this.totalDots() - 1)) {
|
---|
307 | this.step(-1, index);
|
---|
308 | }
|
---|
309 | if (this.autoplayInterval) {
|
---|
310 | this.stopAutoplay();
|
---|
311 | this.allowAutoplay = false;
|
---|
312 | }
|
---|
313 | if (e && e.cancelable) {
|
---|
314 | e.preventDefault();
|
---|
315 | }
|
---|
316 | }
|
---|
317 | navBackward(e, index) {
|
---|
318 | if (this.isCircular() || this._page !== 0) {
|
---|
319 | this.step(1, index);
|
---|
320 | }
|
---|
321 | if (this.autoplayInterval) {
|
---|
322 | this.stopAutoplay();
|
---|
323 | this.allowAutoplay = false;
|
---|
324 | }
|
---|
325 | if (e && e.cancelable) {
|
---|
326 | e.preventDefault();
|
---|
327 | }
|
---|
328 | }
|
---|
329 | onDotClick(e, index) {
|
---|
330 | let page = this._page;
|
---|
331 | if (this.autoplayInterval) {
|
---|
332 | this.stopAutoplay();
|
---|
333 | this.allowAutoplay = false;
|
---|
334 | }
|
---|
335 | if (index > page) {
|
---|
336 | this.navForward(e, index);
|
---|
337 | }
|
---|
338 | else if (index < page) {
|
---|
339 | this.navBackward(e, index);
|
---|
340 | }
|
---|
341 | }
|
---|
342 | step(dir, page) {
|
---|
343 | let totalShiftedItems = this.totalShiftedItems;
|
---|
344 | const isCircular = this.isCircular();
|
---|
345 | if (page != null) {
|
---|
346 | totalShiftedItems = (this._numScroll * page) * -1;
|
---|
347 | if (isCircular) {
|
---|
348 | totalShiftedItems -= this._numVisible;
|
---|
349 | }
|
---|
350 | this.isRemainingItemsAdded = false;
|
---|
351 | }
|
---|
352 | else {
|
---|
353 | totalShiftedItems += (this._numScroll * dir);
|
---|
354 | if (this.isRemainingItemsAdded) {
|
---|
355 | totalShiftedItems += this.remainingItems - (this._numScroll * dir);
|
---|
356 | this.isRemainingItemsAdded = false;
|
---|
357 | }
|
---|
358 | let originalShiftedItems = isCircular ? (totalShiftedItems + this._numVisible) : totalShiftedItems;
|
---|
359 | page = Math.abs(Math.floor((originalShiftedItems / this._numScroll)));
|
---|
360 | }
|
---|
361 | if (isCircular && this.page === (this.totalDots() - 1) && dir === -1) {
|
---|
362 | totalShiftedItems = -1 * (this.value.length + this._numVisible);
|
---|
363 | page = 0;
|
---|
364 | }
|
---|
365 | else if (isCircular && this.page === 0 && dir === 1) {
|
---|
366 | totalShiftedItems = 0;
|
---|
367 | page = (this.totalDots() - 1);
|
---|
368 | }
|
---|
369 | else if (page === (this.totalDots() - 1) && this.remainingItems > 0) {
|
---|
370 | totalShiftedItems += ((this.remainingItems * -1) - (this._numScroll * dir));
|
---|
371 | this.isRemainingItemsAdded = true;
|
---|
372 | }
|
---|
373 | if (this.itemsContainer) {
|
---|
374 | this.itemsContainer.nativeElement.style.transform = this.isVertical() ? `translate3d(0, ${totalShiftedItems * (100 / this._numVisible)}%, 0)` : `translate3d(${totalShiftedItems * (100 / this._numVisible)}%, 0, 0)`;
|
---|
375 | this.itemsContainer.nativeElement.style.transition = 'transform 500ms ease 0s';
|
---|
376 | }
|
---|
377 | this.totalShiftedItems = totalShiftedItems;
|
---|
378 | this._page = page;
|
---|
379 | this.onPage.emit({
|
---|
380 | page: this.page
|
---|
381 | });
|
---|
382 | }
|
---|
383 | startAutoplay() {
|
---|
384 | this.interval = setInterval(() => {
|
---|
385 | if (this.totalDots() > 0) {
|
---|
386 | if (this.page === (this.totalDots() - 1)) {
|
---|
387 | this.step(-1, 0);
|
---|
388 | }
|
---|
389 | else {
|
---|
390 | this.step(-1, this.page + 1);
|
---|
391 | }
|
---|
392 | }
|
---|
393 | }, this.autoplayInterval);
|
---|
394 | }
|
---|
395 | stopAutoplay() {
|
---|
396 | if (this.interval) {
|
---|
397 | clearInterval(this.interval);
|
---|
398 | }
|
---|
399 | }
|
---|
400 | onTransitionEnd() {
|
---|
401 | if (this.itemsContainer) {
|
---|
402 | this.itemsContainer.nativeElement.style.transition = '';
|
---|
403 | if ((this.page === 0 || this.page === (this.totalDots() - 1)) && this.isCircular()) {
|
---|
404 | this.itemsContainer.nativeElement.style.transform = this.isVertical() ? `translate3d(0, ${this.totalShiftedItems * (100 / this._numVisible)}%, 0)` : `translate3d(${this.totalShiftedItems * (100 / this._numVisible)}%, 0, 0)`;
|
---|
405 | }
|
---|
406 | }
|
---|
407 | }
|
---|
408 | onTouchStart(e) {
|
---|
409 | let touchobj = e.changedTouches[0];
|
---|
410 | this.startPos = {
|
---|
411 | x: touchobj.pageX,
|
---|
412 | y: touchobj.pageY
|
---|
413 | };
|
---|
414 | }
|
---|
415 | onTouchMove(e) {
|
---|
416 | if (e.cancelable) {
|
---|
417 | e.preventDefault();
|
---|
418 | }
|
---|
419 | }
|
---|
420 | onTouchEnd(e) {
|
---|
421 | let touchobj = e.changedTouches[0];
|
---|
422 | if (this.isVertical()) {
|
---|
423 | this.changePageOnTouch(e, (touchobj.pageY - this.startPos.y));
|
---|
424 | }
|
---|
425 | else {
|
---|
426 | this.changePageOnTouch(e, (touchobj.pageX - this.startPos.x));
|
---|
427 | }
|
---|
428 | }
|
---|
429 | changePageOnTouch(e, diff) {
|
---|
430 | if (Math.abs(diff) > this.swipeThreshold) {
|
---|
431 | if (diff < 0) {
|
---|
432 | this.navForward(e);
|
---|
433 | }
|
---|
434 | else {
|
---|
435 | this.navBackward(e);
|
---|
436 | }
|
---|
437 | }
|
---|
438 | }
|
---|
439 | bindDocumentListeners() {
|
---|
440 | if (!this.documentResizeListener) {
|
---|
441 | this.documentResizeListener = (e) => {
|
---|
442 | this.calculatePosition();
|
---|
443 | };
|
---|
444 | window.addEventListener('resize', this.documentResizeListener);
|
---|
445 | }
|
---|
446 | }
|
---|
447 | unbindDocumentListeners() {
|
---|
448 | if (this.documentResizeListener) {
|
---|
449 | window.removeEventListener('resize', this.documentResizeListener);
|
---|
450 | this.documentResizeListener = null;
|
---|
451 | }
|
---|
452 | }
|
---|
453 | ngOnDestroy() {
|
---|
454 | if (this.responsiveOptions) {
|
---|
455 | this.unbindDocumentListeners();
|
---|
456 | }
|
---|
457 | if (this.autoplayInterval) {
|
---|
458 | this.stopAutoplay();
|
---|
459 | }
|
---|
460 | }
|
---|
461 | }
|
---|
462 | Carousel.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Carousel, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
---|
463 | Carousel.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: Carousel, selector: "p-carousel", inputs: { page: "page", numVisible: "numVisible", numScroll: "numScroll", responsiveOptions: "responsiveOptions", orientation: "orientation", verticalViewPortHeight: "verticalViewPortHeight", contentClass: "contentClass", indicatorsContentClass: "indicatorsContentClass", indicatorsContentStyle: "indicatorsContentStyle", indicatorStyleClass: "indicatorStyleClass", indicatorStyle: "indicatorStyle", value: "value", circular: "circular", showIndicators: "showIndicators", showNavigators: "showNavigators", autoplayInterval: "autoplayInterval", style: "style", styleClass: "styleClass" }, outputs: { onPage: "onPage" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "headerFacet", first: true, predicate: Header, descendants: true }, { propertyName: "footerFacet", first: true, predicate: Footer, descendants: true }, { propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "itemsContainer", first: true, predicate: ["itemsContainer"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
---|
464 | <div [attr.id]="id" [ngClass]="{'p-carousel p-component':true, 'p-carousel-vertical': isVertical(), 'p-carousel-horizontal': !isVertical()}" [ngStyle]="style" [class]="styleClass">
|
---|
465 | <div class="p-carousel-header" *ngIf="headerFacet || headerTemplate">
|
---|
466 | <ng-content select="p-header"></ng-content>
|
---|
467 | <ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
|
---|
468 | </div>
|
---|
469 | <div [class]="contentClass" [ngClass]="'p-carousel-content'">
|
---|
470 | <div class="p-carousel-container">
|
---|
471 | <button type="button" *ngIf="showNavigators" [ngClass]="{'p-carousel-prev p-link':true, 'p-disabled': isBackwardNavDisabled()}" [disabled]="isBackwardNavDisabled()" (click)="navBackward($event)" pRipple>
|
---|
472 | <span [ngClass]="{'p-carousel-prev-icon pi': true, 'pi-chevron-left': !isVertical(), 'pi-chevron-up': isVertical()}"></span>
|
---|
473 | </button>
|
---|
474 | <div class="p-carousel-items-content" [ngStyle]="{'height': isVertical() ? verticalViewPortHeight : 'auto'}">
|
---|
475 | <div #itemsContainer class="p-carousel-items-container" (transitionend)="onTransitionEnd()" (touchend)="onTouchEnd($event)" (touchstart)="onTouchStart($event)" (touchmove)="onTouchMove($event)">
|
---|
476 | <div *ngFor="let item of clonedItemsForStarting; let index = index" [ngClass]= "{'p-carousel-item p-carousel-item-cloned': true,
|
---|
477 | 'p-carousel-item-active': (totalShiftedItems * -1) === (value.length),
|
---|
478 | 'p-carousel-item-start': 0 === index,
|
---|
479 | 'p-carousel-item-end': (clonedItemsForStarting.length - 1) === index}">
|
---|
480 | <ng-container *ngTemplateOutlet="itemTemplate; context: {$implicit: item}"></ng-container>
|
---|
481 | </div>
|
---|
482 | <div *ngFor="let item of value; let index = index" [ngClass]= "{'p-carousel-item': true,
|
---|
483 | 'p-carousel-item-active': (firstIndex() <= index && lastIndex() >= index),
|
---|
484 | 'p-carousel-item-start': firstIndex() === index,
|
---|
485 | 'p-carousel-item-end': lastIndex() === index}">
|
---|
486 | <ng-container *ngTemplateOutlet="itemTemplate; context: {$implicit: item}"></ng-container>
|
---|
487 | </div>
|
---|
488 | <div *ngFor="let item of clonedItemsForFinishing; let index = index" [ngClass]= "{'p-carousel-item p-carousel-item-cloned': true,
|
---|
489 | 'p-carousel-item-active': ((totalShiftedItems *-1) === numVisible),
|
---|
490 | 'p-carousel-item-start': 0 === index,
|
---|
491 | 'p-carousel-item-end': (clonedItemsForFinishing.length - 1) === index}">
|
---|
492 | <ng-container *ngTemplateOutlet="itemTemplate; context: {$implicit: item}"></ng-container>
|
---|
493 | </div>
|
---|
494 | </div>
|
---|
495 | </div>
|
---|
496 | <button type="button" *ngIf="showNavigators" [ngClass]="{'p-carousel-next p-link': true, 'p-disabled': isForwardNavDisabled()}" [disabled]="isForwardNavDisabled()" (click)="navForward($event)" pRipple>
|
---|
497 | <span [ngClass]="{'p-carousel-prev-icon pi': true, 'pi-chevron-right': !isVertical(), 'pi-chevron-down': isVertical()}"></span>
|
---|
498 | </button>
|
---|
499 | </div>
|
---|
500 | <ul [ngClass]="'p-carousel-indicators p-reset'" [class]="indicatorsContentClass" [ngStyle]="indicatorsContentStyle" *ngIf="showIndicators">
|
---|
501 | <li *ngFor="let totalDot of totalDotsArray(); let i = index" [ngClass]="{'p-carousel-indicator':true,'p-highlight': _page === i}">
|
---|
502 | <button type="button" [ngClass]="'p-link'" (click)="onDotClick($event, i)" [class]="indicatorStyleClass" [ngStyle]="indicatorStyle"></button>
|
---|
503 | </li>
|
---|
504 | </ul>
|
---|
505 | </div>
|
---|
506 | <div class="p-carousel-footer" *ngIf="footerFacet || footerTemplate">
|
---|
507 | <ng-content select="p-footer"></ng-content>
|
---|
508 | <ng-container *ngTemplateOutlet="footerTemplate"></ng-container>
|
---|
509 | </div>
|
---|
510 | </div>
|
---|
511 | `, isInline: true, styles: [".p-carousel{display:flex;flex-direction:column}.p-carousel-content{display:flex;flex-direction:column;overflow:auto}.p-carousel-prev,.p-carousel-next{align-self:center;flex-grow:0;flex-shrink:0;display:flex;justify-content:center;align-items:center;overflow:hidden;position:relative}.p-carousel-container{display:flex;flex-direction:row}.p-carousel-items-content{overflow:hidden;width:100%}.p-carousel-items-container{display:flex;flex-direction:row}.p-carousel-indicators{display:flex;flex-direction:row;justify-content:center;flex-wrap:wrap}.p-carousel-indicator>button{display:flex;align-items:center;justify-content:center}.p-carousel-vertical .p-carousel-container{flex-direction:column}.p-carousel-vertical .p-carousel-items-container{flex-direction:column;height:100%}.p-items-hidden .p-carousel-item{visibility:hidden}.p-items-hidden .p-carousel-item.p-carousel-item-active{visibility:visible}\n"], directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i2.Ripple, selector: "[pRipple]" }, { type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
---|
512 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Carousel, decorators: [{
|
---|
513 | type: Component,
|
---|
514 | args: [{ selector: 'p-carousel', template: `
|
---|
515 | <div [attr.id]="id" [ngClass]="{'p-carousel p-component':true, 'p-carousel-vertical': isVertical(), 'p-carousel-horizontal': !isVertical()}" [ngStyle]="style" [class]="styleClass">
|
---|
516 | <div class="p-carousel-header" *ngIf="headerFacet || headerTemplate">
|
---|
517 | <ng-content select="p-header"></ng-content>
|
---|
518 | <ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
|
---|
519 | </div>
|
---|
520 | <div [class]="contentClass" [ngClass]="'p-carousel-content'">
|
---|
521 | <div class="p-carousel-container">
|
---|
522 | <button type="button" *ngIf="showNavigators" [ngClass]="{'p-carousel-prev p-link':true, 'p-disabled': isBackwardNavDisabled()}" [disabled]="isBackwardNavDisabled()" (click)="navBackward($event)" pRipple>
|
---|
523 | <span [ngClass]="{'p-carousel-prev-icon pi': true, 'pi-chevron-left': !isVertical(), 'pi-chevron-up': isVertical()}"></span>
|
---|
524 | </button>
|
---|
525 | <div class="p-carousel-items-content" [ngStyle]="{'height': isVertical() ? verticalViewPortHeight : 'auto'}">
|
---|
526 | <div #itemsContainer class="p-carousel-items-container" (transitionend)="onTransitionEnd()" (touchend)="onTouchEnd($event)" (touchstart)="onTouchStart($event)" (touchmove)="onTouchMove($event)">
|
---|
527 | <div *ngFor="let item of clonedItemsForStarting; let index = index" [ngClass]= "{'p-carousel-item p-carousel-item-cloned': true,
|
---|
528 | 'p-carousel-item-active': (totalShiftedItems * -1) === (value.length),
|
---|
529 | 'p-carousel-item-start': 0 === index,
|
---|
530 | 'p-carousel-item-end': (clonedItemsForStarting.length - 1) === index}">
|
---|
531 | <ng-container *ngTemplateOutlet="itemTemplate; context: {$implicit: item}"></ng-container>
|
---|
532 | </div>
|
---|
533 | <div *ngFor="let item of value; let index = index" [ngClass]= "{'p-carousel-item': true,
|
---|
534 | 'p-carousel-item-active': (firstIndex() <= index && lastIndex() >= index),
|
---|
535 | 'p-carousel-item-start': firstIndex() === index,
|
---|
536 | 'p-carousel-item-end': lastIndex() === index}">
|
---|
537 | <ng-container *ngTemplateOutlet="itemTemplate; context: {$implicit: item}"></ng-container>
|
---|
538 | </div>
|
---|
539 | <div *ngFor="let item of clonedItemsForFinishing; let index = index" [ngClass]= "{'p-carousel-item p-carousel-item-cloned': true,
|
---|
540 | 'p-carousel-item-active': ((totalShiftedItems *-1) === numVisible),
|
---|
541 | 'p-carousel-item-start': 0 === index,
|
---|
542 | 'p-carousel-item-end': (clonedItemsForFinishing.length - 1) === index}">
|
---|
543 | <ng-container *ngTemplateOutlet="itemTemplate; context: {$implicit: item}"></ng-container>
|
---|
544 | </div>
|
---|
545 | </div>
|
---|
546 | </div>
|
---|
547 | <button type="button" *ngIf="showNavigators" [ngClass]="{'p-carousel-next p-link': true, 'p-disabled': isForwardNavDisabled()}" [disabled]="isForwardNavDisabled()" (click)="navForward($event)" pRipple>
|
---|
548 | <span [ngClass]="{'p-carousel-prev-icon pi': true, 'pi-chevron-right': !isVertical(), 'pi-chevron-down': isVertical()}"></span>
|
---|
549 | </button>
|
---|
550 | </div>
|
---|
551 | <ul [ngClass]="'p-carousel-indicators p-reset'" [class]="indicatorsContentClass" [ngStyle]="indicatorsContentStyle" *ngIf="showIndicators">
|
---|
552 | <li *ngFor="let totalDot of totalDotsArray(); let i = index" [ngClass]="{'p-carousel-indicator':true,'p-highlight': _page === i}">
|
---|
553 | <button type="button" [ngClass]="'p-link'" (click)="onDotClick($event, i)" [class]="indicatorStyleClass" [ngStyle]="indicatorStyle"></button>
|
---|
554 | </li>
|
---|
555 | </ul>
|
---|
556 | </div>
|
---|
557 | <div class="p-carousel-footer" *ngIf="footerFacet || footerTemplate">
|
---|
558 | <ng-content select="p-footer"></ng-content>
|
---|
559 | <ng-container *ngTemplateOutlet="footerTemplate"></ng-container>
|
---|
560 | </div>
|
---|
561 | </div>
|
---|
562 | `, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
|
---|
563 | 'class': 'p-element'
|
---|
564 | }, styles: [".p-carousel{display:flex;flex-direction:column}.p-carousel-content{display:flex;flex-direction:column;overflow:auto}.p-carousel-prev,.p-carousel-next{align-self:center;flex-grow:0;flex-shrink:0;display:flex;justify-content:center;align-items:center;overflow:hidden;position:relative}.p-carousel-container{display:flex;flex-direction:row}.p-carousel-items-content{overflow:hidden;width:100%}.p-carousel-items-container{display:flex;flex-direction:row}.p-carousel-indicators{display:flex;flex-direction:row;justify-content:center;flex-wrap:wrap}.p-carousel-indicator>button{display:flex;align-items:center;justify-content:center}.p-carousel-vertical .p-carousel-container{flex-direction:column}.p-carousel-vertical .p-carousel-items-container{flex-direction:column;height:100%}.p-items-hidden .p-carousel-item{visibility:hidden}.p-items-hidden .p-carousel-item.p-carousel-item-active{visibility:visible}\n"] }]
|
---|
565 | }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { page: [{
|
---|
566 | type: Input
|
---|
567 | }], numVisible: [{
|
---|
568 | type: Input
|
---|
569 | }], numScroll: [{
|
---|
570 | type: Input
|
---|
571 | }], responsiveOptions: [{
|
---|
572 | type: Input
|
---|
573 | }], orientation: [{
|
---|
574 | type: Input
|
---|
575 | }], verticalViewPortHeight: [{
|
---|
576 | type: Input
|
---|
577 | }], contentClass: [{
|
---|
578 | type: Input
|
---|
579 | }], indicatorsContentClass: [{
|
---|
580 | type: Input
|
---|
581 | }], indicatorsContentStyle: [{
|
---|
582 | type: Input
|
---|
583 | }], indicatorStyleClass: [{
|
---|
584 | type: Input
|
---|
585 | }], indicatorStyle: [{
|
---|
586 | type: Input
|
---|
587 | }], value: [{
|
---|
588 | type: Input
|
---|
589 | }], circular: [{
|
---|
590 | type: Input
|
---|
591 | }], showIndicators: [{
|
---|
592 | type: Input
|
---|
593 | }], showNavigators: [{
|
---|
594 | type: Input
|
---|
595 | }], autoplayInterval: [{
|
---|
596 | type: Input
|
---|
597 | }], style: [{
|
---|
598 | type: Input
|
---|
599 | }], styleClass: [{
|
---|
600 | type: Input
|
---|
601 | }], onPage: [{
|
---|
602 | type: Output
|
---|
603 | }], itemsContainer: [{
|
---|
604 | type: ViewChild,
|
---|
605 | args: ['itemsContainer']
|
---|
606 | }], headerFacet: [{
|
---|
607 | type: ContentChild,
|
---|
608 | args: [Header]
|
---|
609 | }], footerFacet: [{
|
---|
610 | type: ContentChild,
|
---|
611 | args: [Footer]
|
---|
612 | }], templates: [{
|
---|
613 | type: ContentChildren,
|
---|
614 | args: [PrimeTemplate]
|
---|
615 | }] } });
|
---|
616 | class CarouselModule {
|
---|
617 | }
|
---|
618 | CarouselModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CarouselModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
---|
619 | CarouselModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CarouselModule, declarations: [Carousel], imports: [CommonModule, SharedModule, RippleModule], exports: [CommonModule, Carousel, SharedModule] });
|
---|
620 | CarouselModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CarouselModule, imports: [[CommonModule, SharedModule, RippleModule], CommonModule, SharedModule] });
|
---|
621 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CarouselModule, decorators: [{
|
---|
622 | type: NgModule,
|
---|
623 | args: [{
|
---|
624 | imports: [CommonModule, SharedModule, RippleModule],
|
---|
625 | exports: [CommonModule, Carousel, SharedModule],
|
---|
626 | declarations: [Carousel]
|
---|
627 | }]
|
---|
628 | }] });
|
---|
629 |
|
---|
630 | /**
|
---|
631 | * Generated bundle index. Do not edit.
|
---|
632 | */
|
---|
633 |
|
---|
634 | export { Carousel, CarouselModule };
|
---|