1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | var __assign = function() {
|
24 | __assign = Object.assign || function __assign(t) {
|
25 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
26 | s = arguments[i];
|
27 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
28 | }
|
29 | return t;
|
30 | };
|
31 | return __assign.apply(this, arguments);
|
32 | };
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | var lGEvents = {
|
40 | afterAppendSlide: 'lgAfterAppendSlide',
|
41 | init: 'lgInit',
|
42 | hasVideo: 'lgHasVideo',
|
43 | containerResize: 'lgContainerResize',
|
44 | updateSlides: 'lgUpdateSlides',
|
45 | afterAppendSubHtml: 'lgAfterAppendSubHtml',
|
46 | beforeOpen: 'lgBeforeOpen',
|
47 | afterOpen: 'lgAfterOpen',
|
48 | slideItemLoad: 'lgSlideItemLoad',
|
49 | beforeSlide: 'lgBeforeSlide',
|
50 | afterSlide: 'lgAfterSlide',
|
51 | posterClick: 'lgPosterClick',
|
52 | dragStart: 'lgDragStart',
|
53 | dragMove: 'lgDragMove',
|
54 | dragEnd: 'lgDragEnd',
|
55 | beforeNextSlide: 'lgBeforeNextSlide',
|
56 | beforePrevSlide: 'lgBeforePrevSlide',
|
57 | beforeClose: 'lgBeforeClose',
|
58 | afterClose: 'lgAfterClose',
|
59 | rotateLeft: 'lgRotateLeft',
|
60 | rotateRight: 'lgRotateRight',
|
61 | flipHorizontal: 'lgFlipHorizontal',
|
62 | flipVertical: 'lgFlipVertical',
|
63 | autoplay: 'lgAutoplay',
|
64 | autoplayStart: 'lgAutoplayStart',
|
65 | autoplayStop: 'lgAutoplayStop',
|
66 | };
|
67 |
|
68 | var mediumZoomSettings = {
|
69 | margin: 40,
|
70 | mediumZoom: true,
|
71 | backgroundColor: '#000',
|
72 | };
|
73 |
|
74 | var MediumZoom = (function () {
|
75 | function MediumZoom(instance, $LG) {
|
76 | var _this = this;
|
77 |
|
78 | this.core = instance;
|
79 | this.$LG = $LG;
|
80 |
|
81 | this.core.getMediaContainerPosition = function () {
|
82 | return {
|
83 | top: _this.settings.margin,
|
84 | bottom: _this.settings.margin,
|
85 | };
|
86 | };
|
87 |
|
88 | var defaultSettings = {
|
89 | controls: false,
|
90 | download: false,
|
91 | counter: false,
|
92 | showCloseIcon: false,
|
93 | extraProps: ['lgBackgroundColor'],
|
94 | closeOnTap: false,
|
95 | enableSwipe: false,
|
96 | enableDrag: false,
|
97 | swipeToClose: false,
|
98 | addClass: this.core.settings.addClass + ' lg-medium-zoom',
|
99 | };
|
100 | this.core.settings = __assign(__assign({}, this.core.settings), defaultSettings);
|
101 |
|
102 | this.settings = __assign(__assign(__assign({}, mediumZoomSettings), this.core.settings), defaultSettings);
|
103 | return this;
|
104 | }
|
105 | MediumZoom.prototype.toggleItemClass = function () {
|
106 | for (var index = 0; index < this.core.items.length; index++) {
|
107 | var $element = this.$LG(this.core.items[index]);
|
108 | $element.toggleClass('lg-medium-zoom-item');
|
109 | }
|
110 | };
|
111 | MediumZoom.prototype.init = function () {
|
112 | var _this = this;
|
113 | if (!this.settings.mediumZoom) {
|
114 | return;
|
115 | }
|
116 | this.core.LGel.on(lGEvents.beforeOpen + ".medium", function () {
|
117 | _this.core.$backdrop.css('background-color', _this.core.galleryItems[_this.core.index].lgBackgroundColor ||
|
118 | _this.settings.backgroundColor);
|
119 | });
|
120 | this.toggleItemClass();
|
121 | this.core.outer.on('click.lg.medium', function () {
|
122 | _this.core.closeGallery();
|
123 | });
|
124 | };
|
125 | MediumZoom.prototype.destroy = function () {
|
126 | this.toggleItemClass();
|
127 | };
|
128 | return MediumZoom;
|
129 | }());
|
130 |
|
131 | export default MediumZoom;
|
132 |
|