Advertisement
Guest User

index.js

a guest
Jan 22nd, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component, Directive, ElementRef, EventEmitter, Input, NgModule, Output, ViewChild } from '@angular/core';
  2. import { CommonModule } from '@angular/common';
  3. import { Gesture, IonicPageModule, NavParams, Platform, ViewController } from 'ionic-angular';
  4. import { DomSanitizer, HammerGestureConfig } from '@angular/platform-browser';
  5. import { Subject as Subject$1 } from 'rxjs/Subject';
  6.  
  7. var FittedImage = (function () {
  8.     function FittedImage() {
  9.         this.onImageResized = new EventEmitter();
  10.         this.loading = true;
  11.         this.currentDimensions = {
  12.             width: 0,
  13.             height: 0,
  14.         };
  15.         this.originalDimensions = {
  16.             width: 0,
  17.             height: 0,
  18.         };
  19.         this.imageStyle = {};
  20.     }
  21.     /**
  22.      * @return {?}
  23.      */
  24.     FittedImage.prototype.ngOnInit = function () {
  25.         var _this = this;
  26.         // Listen to parent resize
  27.         if (this.resizeTriggerer)
  28.             this.resizeSubscription = this.resizeTriggerer.subscribe(function (event) {
  29.                 _this.resize(event);
  30.             });
  31.     };
  32.     /**
  33.      * @return {?}
  34.      */
  35.     FittedImage.prototype.ngOnDestroy = function () {
  36.         this.resizeSubscription.unsubscribe();
  37.     };
  38.     /**
  39.      * Called every time the window gets resized
  40.      * @param {?} event
  41.      * @return {?}
  42.      */
  43.     FittedImage.prototype.resize = function (event) {
  44.         // Save the image dimensions
  45.         this.saveImageDimensions();
  46.     };
  47.     /**
  48.      * Get the real image dimensions and other useful stuff
  49.      * @param {?} event
  50.      * @return {?}
  51.      */
  52.     FittedImage.prototype.imageLoad = function (event) {
  53.         // Save the original dimensions
  54.         this.originalDimensions.width = event.target.width;
  55.         this.originalDimensions.height = event.target.height;
  56.         this.saveImageDimensions();
  57.         // Mark as not loading anymore
  58.         this.loading = false;
  59.     };
  60.     /**
  61.      * Save the image dimensions (when it has the image)
  62.      * @return {?}
  63.      */
  64.     FittedImage.prototype.saveImageDimensions = function () {
  65.         var /** @type {?} */ width = this.originalDimensions.width;
  66.         var /** @type {?} */ height = this.originalDimensions.height;
  67.         if (width / height > this.wrapperWidth / this.wrapperHeight) {
  68.             this.currentDimensions.width = this.wrapperWidth;
  69.             this.currentDimensions.height = height / width * this.wrapperWidth;
  70.         }
  71.         else {
  72.             this.currentDimensions.height = this.wrapperHeight;
  73.             this.currentDimensions.width = width / height * this.wrapperHeight;
  74.         }
  75.         this.imageStyle.width = this.currentDimensions.width + "px";
  76.         this.imageStyle.height = this.currentDimensions.height + "px";
  77.         this.onImageResized.emit({
  78.             width: this.currentDimensions.width,
  79.             height: this.currentDimensions.height,
  80.             originalWidth: this.originalDimensions.width,
  81.             originalHeight: this.originalDimensions.height,
  82.         });
  83.     };
  84.     FittedImage.decorators = [
  85.         { type: Component, args: [{
  86.                     selector: 'fitted-image',
  87.                     template: "<ion-spinner></ion-spinner><div class=\"fitted-image\"><img [hidden]='loading' [src]=\"photo.url\" [ngStyle]=\"imageStyle\" (load)=\"imageLoad($event)\" alt=\"\" /> </div> ",
  88.                     styles: [":host { display: inline-block; } :host .fitted-image { display: inline-block; position: relative; transform-origin: left top; background-repeat: no-repeat; background-position: center center; background-size: contain; text-align: left; vertical-align: top; } .spinner { filter: brightness(0) invert(1); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } :host .fitted-image img { display: inline-block; min-width: 0; max-width: none; transform-origin: left top; vertical-align: top; pointer-events: none; } "],
  89.                 },] },
  90.     ];
  91.     /**
  92.      * @nocollapse
  93.      */
  94.     FittedImage.ctorParameters = function () { return []; };
  95.     FittedImage.propDecorators = {
  96.         'photo': [{ type: Input },],
  97.         'resizeTriggerer': [{ type: Input },],
  98.         'wrapperWidth': [{ type: Input },],
  99.         'wrapperHeight': [{ type: Input },],
  100.         'onImageResized': [{ type: Output },],
  101.     };
  102.     return FittedImage;
  103. }());
  104.  
  105. var ZoomableImage = (function () {
  106.     function ZoomableImage() {
  107.         this.disableScroll = new EventEmitter();
  108.         this.enableScroll = new EventEmitter();
  109.         this.zoomChange = new EventEmitter();
  110.         this.scale = 1;
  111.         this.scaleStart = 1;
  112.         this.maxScale = 3;
  113.         this.minScale = 1;
  114.         this.minScaleBounce = 0.2;
  115.         this.maxScaleBounce = 0.35;
  116.         this.imageWidth = 0;
  117.         this.imageHeight = 0;
  118.         this.originalSize = {
  119.             width: 0,
  120.             height: 0,
  121.         };
  122.         this.position = {
  123.             x: 0,
  124.             y: 0,
  125.         };
  126.         this.scroll = {
  127.             x: 0,
  128.             y: 0,
  129.         };
  130.         this.centerRatio = {
  131.             x: 0,
  132.             y: 0,
  133.         };
  134.         this.centerStart = {
  135.             x: 0,
  136.             y: 0,
  137.         };
  138.         this.panCenterStart = {
  139.             x: 0, y: 0,
  140.         };
  141.         this.containerStyle = {};
  142.         this.imageStyle = {};
  143.     }
  144.     /**
  145.      * @return {?}
  146.      */
  147.     ZoomableImage.prototype.ngOnInit = function () {
  148.         var _this = this;
  149.         // Get the scrollable element
  150.         this.scrollableElement = this.ionScrollContainer.nativeElement.querySelector('.scroll-content');
  151.         // Attach events
  152.         this.attachEvents();
  153.         // Listen to parent resize
  154.         this.resizeSubscription = this.resizeTriggerer.subscribe(function (event) {
  155.             _this.resize(event);
  156.         });
  157.     };
  158.     /**
  159.      * @return {?}
  160.      */
  161.     ZoomableImage.prototype.ngOnDestroy = function () {
  162.         this.scrollableElement.removeEventListener('scroll', this.scrollListener);
  163.         this.resizeSubscription.unsubscribe();
  164.     };
  165.     /**
  166.      * Attach the events to the items
  167.      * @return {?}
  168.      */
  169.     ZoomableImage.prototype.attachEvents = function () {
  170.         // Scroll event
  171.         this.scrollListener = this.scrollEvent.bind(this);
  172.         this.scrollableElement.addEventListener('scroll', this.scrollListener);
  173.     };
  174.     /**
  175.      * Called every time the window gets resized
  176.      * @param {?} event
  177.      * @return {?}
  178.      */
  179.     ZoomableImage.prototype.resize = function (event) {
  180.         // Get the image dimensions
  181.         this.saveImageDimensions();
  182.     };
  183.     /**
  184.      * Called when the image has dimensions
  185.      *
  186.      * @param {?} dimensions
  187.      * @return {?}
  188.      */
  189.     ZoomableImage.prototype.handleImageResized = function (dimensions) {
  190.         this.imageWidth = dimensions.width;
  191.         this.imageHeight = dimensions.height;
  192.         this.originalSize.width = dimensions.originalWidth;
  193.         this.originalSize.height = dimensions.originalHeight;
  194.         this.saveImageDimensions();
  195.     };
  196.     /**
  197.      * Save the image dimensions (when it has the image)
  198.      * @return {?}
  199.      */
  200.     ZoomableImage.prototype.saveImageDimensions = function () {
  201.         var /** @type {?} */ width = this.originalSize.width;
  202.         this.maxScale = Math.max(width / this.imageWidth - this.maxScaleBounce, 1);
  203.         this.displayScale();
  204.     };
  205.     /**
  206.      * While the user is pinching
  207.      *
  208.      * @param {?} event
  209.      * @return {?}
  210.      */
  211.     ZoomableImage.prototype.pinchEvent = function (event) {
  212.         var /** @type {?} */ scale = this.scaleStart * event.scale;
  213.         if (scale > this.maxScale) {
  214.             scale = this.maxScale + (1 - this.maxScale / scale) * this.maxScaleBounce;
  215.         }
  216.         else if (scale < this.minScale) {
  217.             scale = this.minScale - (1 - scale / this.minScale) * this.minScaleBounce;
  218.         }
  219.         this.scale = scale;
  220.         this.displayScale();
  221.         this.zoomChange.emit({
  222.             scale: this.scale,
  223.         });
  224.         event.preventDefault();
  225.     };
  226.     /**
  227.      * When the user starts pinching
  228.      *
  229.      * @param {?} event
  230.      * @return {?}
  231.      */
  232.     ZoomableImage.prototype.pinchStartEvent = function (event) {
  233.         this.scaleStart = this.scale;
  234.         this.setCenter(event);
  235.     };
  236.     /**
  237.      * When the user stops pinching
  238.      *
  239.      * @param {?} event
  240.      * @return {?}
  241.      */
  242.     ZoomableImage.prototype.pinchEndEvent = function (event) {
  243.         this.checkScroll();
  244.         if (this.scale > this.maxScale) {
  245.             this.animateScale(this.maxScale);
  246.             this.zoomChange.emit({
  247.                 scale: this.maxScale,
  248.             });
  249.         }
  250.         else if (this.scale < this.minScale) {
  251.             this.animateScale(this.minScale);
  252.             this.zoomChange.emit({
  253.                 scale: this.minScale,
  254.             });
  255.         }
  256.         else {
  257.             this.zoomChange.emit({
  258.                 scale: this.scale,
  259.             });
  260.         }
  261.     };
  262.     /**
  263.      * When the user double taps on the photo
  264.      *
  265.      * @param {?} event
  266.      * @return {?}
  267.      */
  268.     ZoomableImage.prototype.doubleTapEvent = function (event) {
  269.         this.setCenter(event);
  270.         var /** @type {?} */ scale = this.scale > 1 ? 1 : 2.5;
  271.         if (scale > this.maxScale) {
  272.             scale = this.maxScale;
  273.         }
  274.         this.zoomChange.emit({
  275.             scale: scale,
  276.         });
  277.         this.animateScale(scale);
  278.     };
  279.     /**
  280.      * Called when the user is panning
  281.      *
  282.      * @param {?} event
  283.      * @return {?}
  284.      */
  285.     ZoomableImage.prototype.panEvent = function (event) {
  286.         // calculate center x,y since pan started
  287.         var /** @type {?} */ x = Math.max(Math.floor(this.panCenterStart.x + event.deltaX), 0);
  288.         var /** @type {?} */ y = Math.max(Math.floor(this.panCenterStart.y + event.deltaY), 0);
  289.         this.centerStart.x = x;
  290.         this.centerStart.y = y;
  291.         if (event.isFinal) {
  292.             this.panCenterStart.x = x;
  293.             this.panCenterStart.y = y;
  294.         }
  295.         this.displayScale();
  296.     };
  297.     /**
  298.      * When the user is scrolling
  299.      *
  300.      * @param {?} event
  301.      * @return {?}
  302.      */
  303.     ZoomableImage.prototype.scrollEvent = function (event) {
  304.         this.scroll.x = event.target.scrollLeft;
  305.         this.scroll.y = event.target.scrollTop;
  306.     };
  307.     /**
  308.      * Set the startup center calculated on the image (along with the ratio)
  309.      *
  310.      * @param {?} event
  311.      * @return {?}
  312.      */
  313.     ZoomableImage.prototype.setCenter = function (event) {
  314.         var /** @type {?} */ realImageWidth = this.imageWidth * this.scale;
  315.         var /** @type {?} */ realImageHeight = this.imageHeight * this.scale;
  316.         this.centerStart.x = Math.max(event.center.x - this.position.x * this.scale, 0);
  317.         this.centerStart.y = Math.max(event.center.y - this.position.y * this.scale, 0);
  318.         this.panCenterStart.x = Math.max(event.center.x - this.position.x * this.scale, 0);
  319.         this.panCenterStart.y = Math.max(event.center.y - this.position.y * this.scale, 0);
  320.         this.centerRatio.x = Math.min((this.centerStart.x + this.scroll.x) / realImageWidth, 1);
  321.         this.centerRatio.y = Math.min((this.centerStart.y + this.scroll.y) / realImageHeight, 1);
  322.     };
  323.     /**
  324.      * Calculate the position and set the proper scale to the element and the
  325.      * container
  326.      * @return {?}
  327.      */
  328.     ZoomableImage.prototype.displayScale = function () {
  329.         var /** @type {?} */ realImageWidth = this.imageWidth * this.scale;
  330.         var /** @type {?} */ realImageHeight = this.imageHeight * this.scale;
  331.         this.position.x = Math.max((this.wrapperWidth - realImageWidth) / (2 * this.scale), 0);
  332.         this.position.y = Math.max((this.wrapperHeight - realImageHeight) / (2 * this.scale), 0);
  333.         this.imageStyle.transform = "scale(" + this.scale + ") translate(" + this.position.x + "px, " + this.position.y + "px)";
  334.         this.containerStyle.width = realImageWidth + "px";
  335.         this.containerStyle.height = realImageHeight + "px";
  336.         this.scroll.x = this.centerRatio.x * realImageWidth - this.centerStart.x;
  337.         this.scroll.y = this.centerRatio.y * realImageWidth - this.centerStart.y;
  338.         // Set scroll of the ion scroll
  339.         this.scrollableElement.scrollLeft = this.scroll.x;
  340.         this.scrollableElement.scrollTop = this.scroll.y;
  341.     };
  342.     /**
  343.      * Check wether to disable or enable scroll and then call the events
  344.      * @return {?}
  345.      */
  346.     ZoomableImage.prototype.checkScroll = function () {
  347.         if (this.scale > 1) {
  348.             this.disableScroll.emit({});
  349.         }
  350.         else {
  351.             this.enableScroll.emit({});
  352.         }
  353.     };
  354.     /**
  355.      * Animates to a certain scale (with ease)
  356.      *
  357.      * @param {?} scale
  358.      * @return {?}
  359.      */
  360.     ZoomableImage.prototype.animateScale = function (scale) {
  361.         this.scale += (scale - this.scale) / 5;
  362.         if (Math.abs(this.scale - scale) <= 0.1) {
  363.             this.scale = scale;
  364.         }
  365.         this.displayScale();
  366.         if (Math.abs(this.scale - scale) > 0.1) {
  367.             window.requestAnimationFrame(this.animateScale.bind(this, scale));
  368.         }
  369.         else {
  370.             this.checkScroll();
  371.         }
  372.     };
  373.     ZoomableImage.decorators = [
  374.         { type: Component, args: [{
  375.                     selector: 'zoomable-image',
  376.                     template: "<ion-scroll #ionScrollContainer scrollX=\"true\" scrollY=\"true\" zoom=\"false\"> <div class=\"image\" touch-events direction=\"y\" (pinch)=\"pinchEvent($event)\" (pinchstart)=\"pinchStartEvent($event)\" (pinchend)=\"pinchEndEvent($event)\" (doubletap)=\"doubleTapEvent($event)\" (onpan)=\"panEvent($event)\" [ngStyle]=\"containerStyle\" > <fitted-image [photo]=\"photo\" [ngStyle]=\"imageStyle\" [resizeTriggerer]=\"resizeTriggerer\" [wrapperWidth]=\"wrapperWidth\" [wrapperHeight]=\"wrapperHeight\" (onImageResized)=\"handleImageResized($event)\" ></fitted-image> </div> </ion-scroll> <div class=\"fitted-image-title\" *ngIf=\"photo.title\" >{{ photo.title }}</div> ",
  377.                     styles: [":host { display: block; position: relative; width: 100%; height: 100%; } :host ion-scroll { width: 100%; height: 100%; text-align: left; white-space: nowrap; } :host ion-scroll /deep/ .scroll-zoom-wrapper { width: 100%; height: 100%; } :host ion-scroll .image { display: inline-block; position: relative; min-width: 100%; min-height: 100%; transform-origin: left top; background-repeat: no-repeat; background-position: center center; background-size: contain; text-align: left; vertical-align: top; } :host ion-scroll .image fitted-image { transform-origin: left top; pointer-events: none; } :host .fitted-image-title { position: absolute; bottom: 0; left: 0; width: 100%; padding: 15px; background-color: rgba(0, 0, 0, 0.3); color: white; font-size: 14px; line-height: 18px; text-align: center; z-index: 1; } "],
  378.                 },] },
  379.     ];
  380.     /**
  381.      * @nocollapse
  382.      */
  383.     ZoomableImage.ctorParameters = function () { return []; };
  384.     ZoomableImage.propDecorators = {
  385.         'ionScrollContainer': [{ type: ViewChild, args: ['ionScrollContainer', { read: ElementRef },] },],
  386.         'photo': [{ type: Input },],
  387.         'resizeTriggerer': [{ type: Input },],
  388.         'wrapperWidth': [{ type: Input },],
  389.         'wrapperHeight': [{ type: Input },],
  390.         'disableScroll': [{ type: Output },],
  391.         'enableScroll': [{ type: Output },],
  392.         'zoomChange': [{ type: Output },],
  393.     };
  394.     return ZoomableImage;
  395. }());
  396.  
  397. var GalleryModal = (function () {
  398.     /**
  399.      * @param {?} viewCtrl
  400.      * @param {?} params
  401.      * @param {?} element
  402.      * @param {?} platform
  403.      * @param {?} domSanitizer
  404.      */
  405.     function GalleryModal(viewCtrl, params, element, platform, domSanitizer) {
  406.         this.viewCtrl = viewCtrl;
  407.         this.element = element;
  408.         this.platform = platform;
  409.         this.domSanitizer = domSanitizer;
  410.         this.sliderDisabled = false;
  411.         this.initialSlide = 0;
  412.         this.currentSlide = 0;
  413.         this.sliderLoaded = false;
  414.         this.closeIcon = 'arrow-back';
  415.         this.resizeTriggerer = new Subject$1();
  416.         this.slidesDragging = false;
  417.         this.panUpDownRatio = 0;
  418.         this.panUpDownDeltaY = 0;
  419.         this.dismissed = false;
  420.         this.width = 0;
  421.         this.height = 0;
  422.         this.slidesStyle = {
  423.             visibility: 'hidden',
  424.         };
  425.         this.modalStyle = {
  426.             backgroundColor: 'rgba(0, 0, 0, 1)',
  427.         };
  428.         this.transitionDuration = '200ms';
  429.         this.transitionTimingFunction = 'cubic-bezier(0.33, 0.66, 0.66, 1)';
  430.         this.photos = params.get('photos') || [];
  431.         this.closeIcon = params.get('closeIcon') || 'arrow-back';
  432.         this.initialSlide = params.get('initialSlide') || 0;
  433.         this.initialImage = this.photos[this.initialSlide] || {};
  434.     }
  435.     /**
  436.      * @return {?}
  437.      */
  438.     GalleryModal.prototype.ngOnInit = function () {
  439.         // call resize on init
  440.         this.resize({});
  441.     };
  442.     /**
  443.      * Closes the modal (when user click on CLOSE)
  444.      * @return {?}
  445.      */
  446.     GalleryModal.prototype.dismiss = function () {
  447.         this.viewCtrl.dismiss();
  448.     };
  449.     /**
  450.      * @param {?} event
  451.      * @return {?}
  452.      */
  453.     GalleryModal.prototype.resize = function (event) {
  454.         if (this.slider)
  455.             this.slider.update();
  456.         this.width = this.element.nativeElement.offsetWidth;
  457.         this.height = this.element.nativeElement.offsetHeight;
  458.         this.resizeTriggerer.next({
  459.             width: this.width,
  460.             height: this.height,
  461.         });
  462.     };
  463.     /**
  464.      * @param {?} event
  465.      * @return {?}
  466.      */
  467.     GalleryModal.prototype.orientationChange = function (event) {
  468.         var _this = this;
  469.         // TODO: See if you can remove timeout
  470.         window.setTimeout(function () {
  471.             _this.resize(event);
  472.         }, 150);
  473.     };
  474.     /**
  475.      * When the modal has entered into view
  476.      * @return {?}
  477.      */
  478.     GalleryModal.prototype.ionViewDidEnter = function () {
  479.         this.resize(false);
  480.         this.sliderLoaded = true;
  481.         this.slidesStyle.visibility = 'visible';
  482.     };
  483.     /**
  484.      * Disables the scroll through the slider
  485.      *
  486.      * @param {?} event
  487.      * @return {?}
  488.      */
  489.     GalleryModal.prototype.disableScroll = function (event) {
  490.         if (!this.sliderDisabled) {
  491.             this.currentSlide = this.slider.getActiveIndex();
  492.             this.sliderDisabled = true;
  493.         }
  494.     };
  495.     /**
  496.      * Enables the scroll through the slider
  497.      *
  498.      * @param {?} event
  499.      * @return {?}
  500.      */
  501.     GalleryModal.prototype.enableScroll = function (event) {
  502.         if (this.sliderDisabled) {
  503.             this.slider.slideTo(this.currentSlide, 0, false);
  504.             this.sliderDisabled = false;
  505.         }
  506.     };
  507.     /**
  508.      * Called while dragging to close modal
  509.      *
  510.      * @param {?} event
  511.      * @return {?}
  512.      */
  513.     GalleryModal.prototype.slidesDrag = function (event) {
  514.         this.slidesDragging = true;
  515.     };
  516.     /**
  517.      * Called when the user pans up/down
  518.      *
  519.      * @param {?} event
  520.      * @return {?}
  521.      */
  522.     GalleryModal.prototype.panUpDownEvent = function (event) {
  523.         event.preventDefault();
  524.         if (this.slidesDragging || this.sliderDisabled) {
  525.             return;
  526.         }
  527.         var /** @type {?} */ ratio = (event.distance / (this.height / 2));
  528.         if (ratio > 1) {
  529.             ratio = 1;
  530.         }
  531.         else if (ratio < 0) {
  532.             ratio = 0;
  533.         }
  534.         var /** @type {?} */ scale = (event.deltaY < 0 ? 1 : 1 - (ratio * 0.2));
  535.         var /** @type {?} */ opacity = (event.deltaY < 0 ? 1 - (ratio * 0.5) : 1 - (ratio * 0.2));
  536.         var /** @type {?} */ backgroundOpacity = (event.deltaY < 0 ? 1 : 1 - (ratio * 0.8));
  537.         this.panUpDownRatio = ratio;
  538.         this.panUpDownDeltaY = event.deltaY;
  539.         this.slidesStyle.transform = "translate(0, " + event.deltaY + "px) scale(" + scale + ")";
  540.         this.slidesStyle.opacity = opacity;
  541.         this.modalStyle.backgroundColor = "rgba(0, 0, 0, " + backgroundOpacity + ")";
  542.         delete this.slidesStyle.transitionProperty;
  543.         delete this.slidesStyle.transitionDuration;
  544.         delete this.slidesStyle.transitionTimingFunction;
  545.         delete this.modalStyle.transitionProperty;
  546.         delete this.modalStyle.transitionDuration;
  547.         delete this.modalStyle.transitionTimingFunction;
  548.     };
  549.     /**
  550.      * Called when the user stopped panning up/down
  551.      *
  552.      * @param {?} event
  553.      * @return {?}
  554.      */
  555.     GalleryModal.prototype.panEndEvent = function (event) {
  556.         this.slidesDragging = false;
  557.         this.panUpDownRatio += event.velocityY * 30;
  558.         if (this.panUpDownRatio >= 0.65 && this.panUpDownDeltaY > 0) {
  559.             if (!this.dismissed) {
  560.                 this.dismiss();
  561.             }
  562.             this.dismissed = true;
  563.         }
  564.         else {
  565.             this.slidesStyle.transitionProperty = 'transform';
  566.             this.slidesStyle.transitionTimingFunction = this.transitionTimingFunction;
  567.             this.slidesStyle.transitionDuration = this.transitionDuration;
  568.             this.modalStyle.transitionProperty = 'background-color';
  569.             this.modalStyle.transitionTimingFunction = this.transitionTimingFunction;
  570.             this.modalStyle.transitionDuration = this.transitionDuration;
  571.             this.slidesStyle.transform = 'none';
  572.             this.slidesStyle.opacity = 1;
  573.             this.modalStyle.backgroundColor = 'rgba(0, 0, 0, 1)';
  574.         }
  575.     };
  576.     GalleryModal.decorators = [
  577.         { type: Component, args: [{
  578.                     selector: 'gallery-modal',
  579.                     template: "<ion-content class=\"gallery-modal\" no-bounce [ngStyle]=\"modalStyle\" (window:resize)=\"resize($event)\" (window:orientationchange)=\"orientationChange($event)\" > <button class=\"close-button\" ion-button icon-only (click)=\"dismiss()\"> <ion-icon name=\"{{ closeIcon }}\"></ion-icon> </button> <!-- Initial image while modal is animating --> <div class=\"image-on-top\" [hidden]=\"sliderLoaded\"> <zoomable-image [photo]=\"initialImage\" [resizeTriggerer]=\"resizeTriggerer\" [wrapperWidth]=\"width\" [wrapperHeight]=\"height\" ></zoomable-image> </div> <!-- Slider with images --> <ion-slides class=\"slider\" #slider *ngIf=\"photos.length\" [initialSlide]=\"initialSlide\" [ngStyle]=\"slidesStyle\" touch-events (ionSlideDrag)=\"slidesDrag($event)\" (panup)=\"panUpDownEvent($event)\" (pandown)=\"panUpDownEvent($event)\" (panend)=\"panEndEvent($event)\" (pancancel)=\"panEndEvent($event)\" > <ion-slide *ngFor=\"let photo of photos;\"> <zoomable-image [photo]=\"photo\" [resizeTriggerer]=\"resizeTriggerer\" [wrapperWidth]=\"width\" [wrapperHeight]=\"height\" [ngClass]=\"{ 'swiper-no-swiping': sliderDisabled }\" (disableScroll)=\"disableScroll($event)\" (enableScroll)=\"enableScroll($event)\" ></zoomable-image> </ion-slide> </ion-slides> </ion-content> ",
  580.                     styles: [":host .gallery-modal { position: relative; overflow: hidden; } :host .gallery-modal .close-button { position: absolute; top: 10px; left: 5px; background: none; box-shadow: none; z-index: 10; } :host .gallery-modal .close-button.button-ios { top: 20px; } :host .gallery-modal .slider /deep/ .slide-zoom { position: relative; height: 100%; } :host .gallery-modal .image-on-top { display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; } :host .gallery-modal .image-on-top fitted-image { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } "],
  581.                 },] },
  582.     ];
  583.     /**
  584.      * @nocollapse
  585.      */
  586.     GalleryModal.ctorParameters = function () { return [
  587.         { type: ViewController, },
  588.         { type: NavParams, },
  589.         { type: ElementRef, },
  590.         { type: Platform, },
  591.         { type: DomSanitizer, },
  592.     ]; };
  593.     GalleryModal.propDecorators = {
  594.         'slider': [{ type: ViewChild, args: ['slider',] },],
  595.     };
  596.     return GalleryModal;
  597. }());
  598.  
  599. var TouchEventsDirective = (function () {
  600.     /**
  601.      * @param {?} el
  602.      */
  603.     function TouchEventsDirective(el) {
  604.         this.el = el;
  605.         this.direction = 'x';
  606.         this.threshold = 10;
  607.         this.pinch = new EventEmitter();
  608.         this.pinchstart = new EventEmitter();
  609.         this.pinchend = new EventEmitter();
  610.         this.onpan = new EventEmitter();
  611.         this.panup = new EventEmitter();
  612.         this.pandown = new EventEmitter();
  613.         this.panleft = new EventEmitter();
  614.         this.panright = new EventEmitter();
  615.         this.panend = new EventEmitter();
  616.         this.pancancel = new EventEmitter();
  617.         this.doubletap = new EventEmitter();
  618.     }
  619.     /**
  620.      * @return {?}
  621.      */
  622.     TouchEventsDirective.prototype.ngOnInit = function () {
  623.         var _this = this;
  624.         this.gestureListener = new Gesture(this.el.nativeElement, {
  625.             domEvents: false,
  626.             enable: true,
  627.             direction: this.direction,
  628.             threshold: this.threshold,
  629.         });
  630.         this.gestureListener.listen();
  631.         this.gestureListener.on('pinch', function (event) {
  632.             _this.pinch.emit(event);
  633.         });
  634.         this.gestureListener.on('pinchstart', function (event) {
  635.             _this.pinchstart.emit(event);
  636.         });
  637.         this.gestureListener.on('pinchend', function (event) {
  638.             _this.pinchend.emit(event);
  639.         });
  640.         this.gestureListener.on('pan', function (event) {
  641.             _this.onpan.emit(event);
  642.         });
  643.         this.gestureListener.on('panup', function (event) {
  644.             _this.panup.emit(event);
  645.         });
  646.         this.gestureListener.on('pandown', function (event) {
  647.             _this.pandown.emit(event);
  648.         });
  649.         this.gestureListener.on('panleft', function (event) {
  650.             _this.panleft.emit(event);
  651.         });
  652.         this.gestureListener.on('panright', function (event) {
  653.             _this.panright.emit(event);
  654.         });
  655.         this.gestureListener.on('panend', function (event) {
  656.             _this.panend.emit(event);
  657.         });
  658.         this.gestureListener.on('pancancel', function (event) {
  659.             _this.pancancel.emit(event);
  660.         });
  661.         this.gestureListener.on('doubletap', function (event) {
  662.             _this.doubletap.emit(event);
  663.         });
  664.     };
  665.     /**
  666.      * @return {?}
  667.      */
  668.     TouchEventsDirective.prototype.ngOnDestroy = function () {
  669.         this.gestureListener.destroy();
  670.     };
  671.     TouchEventsDirective.decorators = [
  672.         { type: Directive, args: [{
  673.                     selector: '[touch-events]'
  674.                 },] },
  675.     ];
  676.     /**
  677.      * @nocollapse
  678.      */
  679.     TouchEventsDirective.ctorParameters = function () { return [
  680.         { type: ElementRef, },
  681.     ]; };
  682.     TouchEventsDirective.propDecorators = {
  683.         'direction': [{ type: Input },],
  684.         'threshold': [{ type: Input },],
  685.         'pinch': [{ type: Output },],
  686.         'pinchstart': [{ type: Output },],
  687.         'pinchend': [{ type: Output },],
  688.         'onpan': [{ type: Output },],
  689.         'panup': [{ type: Output },],
  690.         'pandown': [{ type: Output },],
  691.         'panleft': [{ type: Output },],
  692.         'panright': [{ type: Output },],
  693.         'panend': [{ type: Output },],
  694.         'pancancel': [{ type: Output },],
  695.         'doubletap': [{ type: Output },],
  696.     };
  697.     return TouchEventsDirective;
  698. }());
  699.  
  700. var __extends = (undefined && undefined.__extends) || (function () {
  701.     var extendStatics = Object.setPrototypeOf ||
  702.         ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  703.         function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  704.     return function (d, b) {
  705.         extendStatics(d, b);
  706.         function __() { this.constructor = d; }
  707.         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  708.     };
  709. })();
  710. var GalleryModalHammerConfig = (function (_super) {
  711.     __extends(GalleryModalHammerConfig, _super);
  712.     function GalleryModalHammerConfig() {
  713.         var _this = _super !== null && _super.apply(this, arguments) || this;
  714.         _this.overrides = {
  715.             pan: {
  716.                 direction: 30,
  717.             },
  718.             press: {
  719.                 time: 300,
  720.             },
  721.         };
  722.         return _this;
  723.     }
  724.     return GalleryModalHammerConfig;
  725. }(HammerGestureConfig));
  726.  
  727. var GalleryModalModule = (function () {
  728.     function GalleryModalModule() {
  729.     }
  730.     GalleryModalModule.decorators = [
  731.         { type: NgModule, args: [{
  732.                     imports: [
  733.                         CommonModule,
  734.                         IonicPageModule.forChild(TouchEventsDirective),
  735.                         IonicPageModule.forChild(FittedImage),
  736.                         IonicPageModule.forChild(ZoomableImage),
  737.                         IonicPageModule.forChild(GalleryModal),
  738.                     ],
  739.                     declarations: [
  740.                         FittedImage,
  741.                         ZoomableImage,
  742.                         GalleryModal,
  743.                         TouchEventsDirective,
  744.                     ],
  745.                     exports: [
  746.                         FittedImage,
  747.                         ZoomableImage,
  748.                         GalleryModal,
  749.                         TouchEventsDirective,
  750.                     ],
  751.                     entryComponents: [
  752.                         GalleryModal,
  753.                     ],
  754.                 },] },
  755.     ];
  756.     /**
  757.      * @nocollapse
  758.      */
  759.     GalleryModalModule.ctorParameters = function () { return []; };
  760.     return GalleryModalModule;
  761. }());
  762.  
  763. export { GalleryModalModule, FittedImage, ZoomableImage, GalleryModal, GalleryModalHammerConfig, TouchEventsDirective };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement