UNPKG

14.5 kBSource Map (JSON)View Raw
1{"version":3,"file":"primeng-galleria.umd.js","sources":["ng://primeng/galleria/galleria.ts"],"sourcesContent":["import {NgModule,Component,ElementRef,AfterViewChecked,AfterViewInit,OnDestroy,Input,Output,EventEmitter,ChangeDetectionStrategy} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler} from 'primeng/dom';\n\n@Component({\n selector: 'p-galleria',\n template: `\n <div [ngClass]=\"{'ui-galleria ui-widget ui-widget-content ui-corner-all':true}\" [ngStyle]=\"style\" [class]=\"styleClass\" [style.width.px]=\"panelWidth\">\n <ul class=\"ui-galleria-panel-wrapper\" [style.width.px]=\"panelWidth\" [style.height.px]=\"panelHeight\">\n <li *ngFor=\"let image of images;let i=index\" class=\"ui-galleria-panel\" [ngClass]=\"{'ui-helper-hidden':i!=activeIndex}\"\n [style.width.px]=\"panelWidth\" [style.height.px]=\"panelHeight\" (click)=\"clickImage($event,image,i)\">\n <img class=\"ui-panel-images\" [src]=\"image.source\" [alt]=\"image.alt\" [title]=\"image.title\"/>\n </li>\n </ul>\n <div [ngClass]=\"{'ui-galleria-filmstrip-wrapper':true}\" *ngIf=\"showFilmstrip\">\n <ul class=\"ui-galleria-filmstrip\" style=\"transition:left 1s\" [style.left.px]=\"stripLeft\">\n <li #frame *ngFor=\"let image of images;let i=index\" [ngClass]=\"{'ui-galleria-frame-active':i==activeIndex}\" class=\"ui-galleria-frame\" (click)=\"frameClick(frame)\"\n [style.width.px]=\"frameWidth\" [style.height.px]=\"frameHeight\" [style.transition]=\"'opacity 0.75s ease'\">\n <div class=\"ui-galleria-frame-content\">\n <img [src]=\"image.source\" [alt]=\"image.alt\" [title]=\"image.title\" class=\"ui-galleria-frame-image\"\n [style.width.px]=\"frameWidth\" [style.height.px]=\"frameHeight\">\n </div>\n </li>\n </ul>\n </div>\n <div class=\"ui-galleria-nav-prev pi pi-fw pi-chevron-left\" (click)=\"clickNavLeft()\" [style.bottom.px]=\"frameHeight/2\" *ngIf=\"activeIndex !== 0\"></div>\n <div class=\"ui-galleria-nav-next pi pi-fw pi-chevron-right\" (click)=\"clickNavRight()\" [style.bottom.px]=\"frameHeight/2\"></div>\n <div class=\"ui-galleria-caption\" *ngIf=\"showCaption&&images\" style=\"display:block\">\n <h4>{{images[activeIndex]?.title}}</h4><p>{{images[activeIndex]?.alt}}</p>\n </div>\n </div>\n `,\n changeDetection: ChangeDetectionStrategy.Default\n})\nexport class Galleria implements AfterViewChecked,AfterViewInit,OnDestroy {\n \n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() panelWidth: number = 600;\n\n @Input() panelHeight: number = 400;\n\n @Input() frameWidth: number = 60;\n \n @Input() frameHeight: number = 40;\n\n @Input() activeIndex: number = 0;\n\n @Input() showFilmstrip: boolean = true;\n\n @Input() autoPlay: boolean = true;\n\n @Input() transitionInterval: number = 4000;\n\n @Input() showCaption: boolean = true;\n\n @Input() effectDuration: number = 500;\n \n @Output() onImageClicked = new EventEmitter();\n\n @Output() onImageChange = new EventEmitter();\n \n _images: any[];\n \n slideshowActive: boolean;\n \n public container: any;\n \n public panelWrapper: any;\n \n public panels: any;\n \n public caption: any;\n \n public stripWrapper: any;\n \n public strip: any;\n \n public frames: any;\n \n public interval: any;\n \n public stripLeft: number = 0;\n \n public imagesChanged: boolean;\n \n public initialized: boolean;\n\n constructor(public el: ElementRef) {}\n \n ngAfterViewChecked() {\n if (this.imagesChanged) {\n this.stopSlideshow();\n Promise.resolve(null).then(() => {\n this.render();\n this.imagesChanged = false;\n });\n }\n }\n\n @Input() get images(): any[] {\n return this._images;\n }\n set images(value:any[]) {\n this._images = value;\n this.imagesChanged = true;\n\n if (this.initialized) {\n this.activeIndex = 0;\n }\n }\n \n ngAfterViewInit() {\n this.container = this.el.nativeElement.children[0];\n this.panelWrapper = DomHandler.findSingle(this.el.nativeElement, 'ul.ui-galleria-panel-wrapper');\n this.initialized = true;\n \n if (this.showFilmstrip) {\n this.stripWrapper = DomHandler.findSingle(this.container,'div.ui-galleria-filmstrip-wrapper');\n this.strip = DomHandler.findSingle(this.stripWrapper,'ul.ui-galleria-filmstrip');\n }\n \n if (this.images && this.images.length) {\n this.render();\n } \n }\n \n render() {\n this.panels = DomHandler.find(this.panelWrapper, 'li.ui-galleria-panel'); \n \n if (this.showFilmstrip) {\n this.frames = DomHandler.find(this.strip,'li.ui-galleria-frame');\n this.stripWrapper.style.width = DomHandler.width(this.panelWrapper) - 50 + 'px';\n this.stripWrapper.style.height = this.frameHeight + 'px';\n }\n \n if (this.showCaption) {\n this.caption = DomHandler.findSingle(this.container,'div.ui-galleria-caption');\n this.caption.style.bottom = this.showFilmstrip ? DomHandler.getOuterHeight(this.stripWrapper,true) + 'px' : 0 + 'px';\n this.caption.style.width = DomHandler.width(this.panelWrapper) + 'px';\n }\n \n if (this.autoPlay) {\n this.startSlideshow();\n }\n \n this.container.style.visibility = 'visible';\n }\n \n startSlideshow() {\n this.interval = setInterval(() => {\n this.next();\n }, this.transitionInterval);\n \n this.slideshowActive = true;\n }\n \n stopSlideshow() {\n if (this.interval) {\n clearInterval(this.interval);\n }\n \n this.slideshowActive = false;\n }\n \n clickNavRight() {\n if (this.slideshowActive) {\n this.stopSlideshow();\n }\n this.next();\n } \n \n clickNavLeft() {\n if (this.slideshowActive) {\n this.stopSlideshow();\n }\n this.prev();\n }\n \n frameClick(frame) {\n if (this.slideshowActive) {\n this.stopSlideshow();\n }\n \n this.select(DomHandler.index(frame), false);\n }\n \n prev() {\n if (this.activeIndex !== 0) {\n this.select(this.activeIndex - 1, true);\n }\n }\n \n next() {\n if (this.activeIndex !== (this.panels.length-1)) {\n this.select(this.activeIndex + 1, true);\n }\n else {\n this.select(0, false);\n this.stripLeft = 0;\n }\n }\n \n select(index, reposition) {\n if (index !== this.activeIndex) { \n let oldPanel = this.panels[this.activeIndex],\n newPanel = this.panels[index];\n \n DomHandler.fadeIn(newPanel, this.effectDuration);\n \n if (this.showFilmstrip) {\n let oldFrame = this.frames[this.activeIndex],\n newFrame = this.frames[index];\n \n if (reposition === undefined || reposition === true) {\n let frameLeft = newFrame.offsetLeft,\n stepFactor = this.frameWidth + parseInt(getComputedStyle(newFrame)['margin-right'], 10),\n stripLeft = this.strip.offsetLeft,\n frameViewportLeft = frameLeft + stripLeft,\n frameViewportRight = frameViewportLeft + this.frameWidth;\n \n if (frameViewportRight > DomHandler.width(this.stripWrapper))\n this.stripLeft -= stepFactor;\n else if (frameViewportLeft < 0)\n this.stripLeft += stepFactor;\n }\n }\n \n this.activeIndex = index;\n\n this.onImageChange.emit({index: index});\n }\n }\n \n clickImage(event, image, i) {\n this.onImageClicked.emit({originalEvent: event, image: image, index: i})\n }\n \n ngOnDestroy() {\n this.stopSlideshow();\n }\n\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Galleria],\n declarations: [Galleria]\n})\nexport class GalleriaModule { }"],"names":["EventEmitter","DomHandler","ElementRef","Input","Output","Component","ChangeDetectionStrategy","NgModule","CommonModule"],"mappings":";;;;;;;;;;;;AAAA;QA0FI,kBAAmB,EAAc;YAAd,OAAE,GAAF,EAAE,CAAY;YAlDxB,eAAU,GAAW,GAAG,CAAC;YAEzB,gBAAW,GAAW,GAAG,CAAC;YAE1B,eAAU,GAAW,EAAE,CAAC;YAExB,gBAAW,GAAW,EAAE,CAAC;YAEzB,gBAAW,GAAW,CAAC,CAAC;YAExB,kBAAa,GAAY,IAAI,CAAC;YAE9B,aAAQ,GAAY,IAAI,CAAC;YAEzB,uBAAkB,GAAW,IAAI,CAAC;YAElC,gBAAW,GAAY,IAAI,CAAC;YAE5B,mBAAc,GAAW,GAAG,CAAC;YAE5B,mBAAc,GAAG,IAAIA,iBAAY,EAAE,CAAC;YAEpC,kBAAa,GAAG,IAAIA,iBAAY,EAAE,CAAC;YAsBtC,cAAS,GAAW,CAAC,CAAC;SAMQ;QAErC,qCAAkB,GAAlB;YAAA,iBAQC;YAPG,IAAI,IAAI,CAAC,aAAa,EAAE;gBACpB,IAAI,CAAC,aAAa,EAAE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