UNPKG

22.3 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.default = void 0;
5
6var _ssrWindow = require("ssr-window");
7
8var _dom = _interopRequireDefault(require("../../utils/dom"));
9
10var _utils = require("../../utils/utils");
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
16var Zoom = {
17 // Calc Scale From Multi-touches
18 getDistanceBetweenTouches: function getDistanceBetweenTouches(e) {
19 if (e.targetTouches.length < 2) return 1;
20 var x1 = e.targetTouches[0].pageX;
21 var y1 = e.targetTouches[0].pageY;
22 var x2 = e.targetTouches[1].pageX;
23 var y2 = e.targetTouches[1].pageY;
24 var distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
25 return distance;
26 },
27 // Events
28 onGestureStart: function onGestureStart(e) {
29 var swiper = this;
30 var support = swiper.support;
31 var params = swiper.params.zoom;
32 var zoom = swiper.zoom;
33 var gesture = zoom.gesture;
34 zoom.fakeGestureTouched = false;
35 zoom.fakeGestureMoved = false;
36
37 if (!support.gestures) {
38 if (e.type !== 'touchstart' || e.type === 'touchstart' && e.targetTouches.length < 2) {
39 return;
40 }
41
42 zoom.fakeGestureTouched = true;
43 gesture.scaleStart = Zoom.getDistanceBetweenTouches(e);
44 }
45
46 if (!gesture.$slideEl || !gesture.$slideEl.length) {
47 gesture.$slideEl = (0, _dom.default)(e.target).closest("." + swiper.params.slideClass);
48 if (gesture.$slideEl.length === 0) gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
49 gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target');
50 gesture.$imageWrapEl = gesture.$imageEl.parent("." + params.containerClass);
51 gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
52
53 if (gesture.$imageWrapEl.length === 0) {
54 gesture.$imageEl = undefined;
55 return;
56 }
57 }
58
59 if (gesture.$imageEl) {
60 gesture.$imageEl.transition(0);
61 }
62
63 swiper.zoom.isScaling = true;
64 },
65 onGestureChange: function onGestureChange(e) {
66 var swiper = this;
67 var support = swiper.support;
68 var params = swiper.params.zoom;
69 var zoom = swiper.zoom;
70 var gesture = zoom.gesture;
71
72 if (!support.gestures) {
73 if (e.type !== 'touchmove' || e.type === 'touchmove' && e.targetTouches.length < 2) {
74 return;
75 }
76
77 zoom.fakeGestureMoved = true;
78 gesture.scaleMove = Zoom.getDistanceBetweenTouches(e);
79 }
80
81 if (!gesture.$imageEl || gesture.$imageEl.length === 0) {
82 if (e.type === 'gesturechange') zoom.onGestureStart(e);
83 return;
84 }
85
86 if (support.gestures) {
87 zoom.scale = e.scale * zoom.currentScale;
88 } else {
89 zoom.scale = gesture.scaleMove / gesture.scaleStart * zoom.currentScale;
90 }
91
92 if (zoom.scale > gesture.maxRatio) {
93 zoom.scale = gesture.maxRatio - 1 + Math.pow(zoom.scale - gesture.maxRatio + 1, 0.5);
94 }
95
96 if (zoom.scale < params.minRatio) {
97 zoom.scale = params.minRatio + 1 - Math.pow(params.minRatio - zoom.scale + 1, 0.5);
98 }
99
100 gesture.$imageEl.transform("translate3d(0,0,0) scale(" + zoom.scale + ")");
101 },
102 onGestureEnd: function onGestureEnd(e) {
103 var swiper = this;
104 var device = swiper.device;
105 var support = swiper.support;
106 var params = swiper.params.zoom;
107 var zoom = swiper.zoom;
108 var gesture = zoom.gesture;
109
110 if (!support.gestures) {
111 if (!zoom.fakeGestureTouched || !zoom.fakeGestureMoved) {
112 return;
113 }
114
115 if (e.type !== 'touchend' || e.type === 'touchend' && e.changedTouches.length < 2 && !device.android) {
116 return;
117 }
118
119 zoom.fakeGestureTouched = false;
120 zoom.fakeGestureMoved = false;
121 }
122
123 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
124 zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio);
125 gesture.$imageEl.transition(swiper.params.speed).transform("translate3d(0,0,0) scale(" + zoom.scale + ")");
126 zoom.currentScale = zoom.scale;
127 zoom.isScaling = false;
128 if (zoom.scale === 1) gesture.$slideEl = undefined;
129 },
130 onTouchStart: function onTouchStart(e) {
131 var swiper = this;
132 var device = swiper.device;
133 var zoom = swiper.zoom;
134 var gesture = zoom.gesture,
135 image = zoom.image;
136 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
137 if (image.isTouched) return;
138 if (device.android && e.cancelable) e.preventDefault();
139 image.isTouched = true;
140 image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
141 image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
142 },
143 onTouchMove: function onTouchMove(e) {
144 var swiper = this;
145 var zoom = swiper.zoom;
146 var gesture = zoom.gesture,
147 image = zoom.image,
148 velocity = zoom.velocity;
149 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
150 swiper.allowClick = false;
151 if (!image.isTouched || !gesture.$slideEl) return;
152
153 if (!image.isMoved) {
154 image.width = gesture.$imageEl[0].offsetWidth;
155 image.height = gesture.$imageEl[0].offsetHeight;
156 image.startX = (0, _utils.getTranslate)(gesture.$imageWrapEl[0], 'x') || 0;
157 image.startY = (0, _utils.getTranslate)(gesture.$imageWrapEl[0], 'y') || 0;
158 gesture.slideWidth = gesture.$slideEl[0].offsetWidth;
159 gesture.slideHeight = gesture.$slideEl[0].offsetHeight;
160 gesture.$imageWrapEl.transition(0);
161
162 if (swiper.rtl) {
163 image.startX = -image.startX;
164 image.startY = -image.startY;
165 }
166 } // Define if we need image drag
167
168
169 var scaledWidth = image.width * zoom.scale;
170 var scaledHeight = image.height * zoom.scale;
171 if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) return;
172 image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
173 image.maxX = -image.minX;
174 image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
175 image.maxY = -image.minY;
176 image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
177 image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
178
179 if (!image.isMoved && !zoom.isScaling) {
180 if (swiper.isHorizontal() && (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x || Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x)) {
181 image.isTouched = false;
182 return;
183 }
184
185 if (!swiper.isHorizontal() && (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y || Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y)) {
186 image.isTouched = false;
187 return;
188 }
189 }
190
191 if (e.cancelable) {
192 e.preventDefault();
193 }
194
195 e.stopPropagation();
196 image.isMoved = true;
197 image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX;
198 image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY;
199
200 if (image.currentX < image.minX) {
201 image.currentX = image.minX + 1 - Math.pow(image.minX - image.currentX + 1, 0.8);
202 }
203
204 if (image.currentX > image.maxX) {
205 image.currentX = image.maxX - 1 + Math.pow(image.currentX - image.maxX + 1, 0.8);
206 }
207
208 if (image.currentY < image.minY) {
209 image.currentY = image.minY + 1 - Math.pow(image.minY - image.currentY + 1, 0.8);
210 }
211
212 if (image.currentY > image.maxY) {
213 image.currentY = image.maxY - 1 + Math.pow(image.currentY - image.maxY + 1, 0.8);
214 } // Velocity
215
216
217 if (!velocity.prevPositionX) velocity.prevPositionX = image.touchesCurrent.x;
218 if (!velocity.prevPositionY) velocity.prevPositionY = image.touchesCurrent.y;
219 if (!velocity.prevTime) velocity.prevTime = Date.now();
220 velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2;
221 velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2;
222 if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) velocity.x = 0;
223 if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) velocity.y = 0;
224 velocity.prevPositionX = image.touchesCurrent.x;
225 velocity.prevPositionY = image.touchesCurrent.y;
226 velocity.prevTime = Date.now();
227 gesture.$imageWrapEl.transform("translate3d(" + image.currentX + "px, " + image.currentY + "px,0)");
228 },
229 onTouchEnd: function onTouchEnd() {
230 var swiper = this;
231 var zoom = swiper.zoom;
232 var gesture = zoom.gesture,
233 image = zoom.image,
234 velocity = zoom.velocity;
235 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
236
237 if (!image.isTouched || !image.isMoved) {
238 image.isTouched = false;
239 image.isMoved = false;
240 return;
241 }
242
243 image.isTouched = false;
244 image.isMoved = false;
245 var momentumDurationX = 300;
246 var momentumDurationY = 300;
247 var momentumDistanceX = velocity.x * momentumDurationX;
248 var newPositionX = image.currentX + momentumDistanceX;
249 var momentumDistanceY = velocity.y * momentumDurationY;
250 var newPositionY = image.currentY + momentumDistanceY; // Fix duration
251
252 if (velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x);
253 if (velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y);
254 var momentumDuration = Math.max(momentumDurationX, momentumDurationY);
255 image.currentX = newPositionX;
256 image.currentY = newPositionY; // Define if we need image drag
257
258 var scaledWidth = image.width * zoom.scale;
259 var scaledHeight = image.height * zoom.scale;
260 image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
261 image.maxX = -image.minX;
262 image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
263 image.maxY = -image.minY;
264 image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX);
265 image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY);
266 gesture.$imageWrapEl.transition(momentumDuration).transform("translate3d(" + image.currentX + "px, " + image.currentY + "px,0)");
267 },
268 onTransitionEnd: function onTransitionEnd() {
269 var swiper = this;
270 var zoom = swiper.zoom;
271 var gesture = zoom.gesture;
272
273 if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) {
274 if (gesture.$imageEl) {
275 gesture.$imageEl.transform('translate3d(0,0,0) scale(1)');
276 }
277
278 if (gesture.$imageWrapEl) {
279 gesture.$imageWrapEl.transform('translate3d(0,0,0)');
280 }
281
282 zoom.scale = 1;
283 zoom.currentScale = 1;
284 gesture.$slideEl = undefined;
285 gesture.$imageEl = undefined;
286 gesture.$imageWrapEl = undefined;
287 }
288 },
289 // Toggle Zoom
290 toggle: function toggle(e) {
291 var swiper = this;
292 var zoom = swiper.zoom;
293
294 if (zoom.scale && zoom.scale !== 1) {
295 // Zoom Out
296 zoom.out();
297 } else {
298 // Zoom In
299 zoom.in(e);
300 }
301 },
302 in: function _in(e) {
303 var swiper = this;
304 var window = (0, _ssrWindow.getWindow)();
305 var zoom = swiper.zoom;
306 var params = swiper.params.zoom;
307 var gesture = zoom.gesture,
308 image = zoom.image;
309
310 if (!gesture.$slideEl) {
311 if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
312 gesture.$slideEl = swiper.$wrapperEl.children("." + swiper.params.slideActiveClass);
313 } else {
314 gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
315 }
316
317 gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target');
318 gesture.$imageWrapEl = gesture.$imageEl.parent("." + params.containerClass);
319 }
320
321 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
322 gesture.$slideEl.addClass("" + params.zoomedSlideClass);
323 var touchX;
324 var touchY;
325 var offsetX;
326 var offsetY;
327 var diffX;
328 var diffY;
329 var translateX;
330 var translateY;
331 var imageWidth;
332 var imageHeight;
333 var scaledWidth;
334 var scaledHeight;
335 var translateMinX;
336 var translateMinY;
337 var translateMaxX;
338 var translateMaxY;
339 var slideWidth;
340 var slideHeight;
341
342 if (typeof image.touchesStart.x === 'undefined' && e) {
343 touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX;
344 touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY;
345 } else {
346 touchX = image.touchesStart.x;
347 touchY = image.touchesStart.y;
348 }
349
350 zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
351 zoom.currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
352
353 if (e) {
354 slideWidth = gesture.$slideEl[0].offsetWidth;
355 slideHeight = gesture.$slideEl[0].offsetHeight;
356 offsetX = gesture.$slideEl.offset().left + window.scrollX;
357 offsetY = gesture.$slideEl.offset().top + window.scrollY;
358 diffX = offsetX + slideWidth / 2 - touchX;
359 diffY = offsetY + slideHeight / 2 - touchY;
360 imageWidth = gesture.$imageEl[0].offsetWidth;
361 imageHeight = gesture.$imageEl[0].offsetHeight;
362 scaledWidth = imageWidth * zoom.scale;
363 scaledHeight = imageHeight * zoom.scale;
364 translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0);
365 translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0);
366 translateMaxX = -translateMinX;
367 translateMaxY = -translateMinY;
368 translateX = diffX * zoom.scale;
369 translateY = diffY * zoom.scale;
370
371 if (translateX < translateMinX) {
372 translateX = translateMinX;
373 }
374
375 if (translateX > translateMaxX) {
376 translateX = translateMaxX;
377 }
378
379 if (translateY < translateMinY) {
380 translateY = translateMinY;
381 }
382
383 if (translateY > translateMaxY) {
384 translateY = translateMaxY;
385 }
386 } else {
387 translateX = 0;
388 translateY = 0;
389 }
390
391 gesture.$imageWrapEl.transition(300).transform("translate3d(" + translateX + "px, " + translateY + "px,0)");
392 gesture.$imageEl.transition(300).transform("translate3d(0,0,0) scale(" + zoom.scale + ")");
393 },
394 out: function out() {
395 var swiper = this;
396 var zoom = swiper.zoom;
397 var params = swiper.params.zoom;
398 var gesture = zoom.gesture;
399
400 if (!gesture.$slideEl) {
401 if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
402 gesture.$slideEl = swiper.$wrapperEl.children("." + swiper.params.slideActiveClass);
403 } else {
404 gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
405 }
406
407 gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target');
408 gesture.$imageWrapEl = gesture.$imageEl.parent("." + params.containerClass);
409 }
410
411 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
412 zoom.scale = 1;
413 zoom.currentScale = 1;
414 gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)');
415 gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)');
416 gesture.$slideEl.removeClass("" + params.zoomedSlideClass);
417 gesture.$slideEl = undefined;
418 },
419 toggleGestures: function toggleGestures(method) {
420 var swiper = this;
421 var zoom = swiper.zoom;
422 var selector = zoom.slideSelector,
423 passive = zoom.passiveListener;
424 swiper.$wrapperEl[method]('gesturestart', selector, zoom.onGestureStart, passive);
425 swiper.$wrapperEl[method]('gesturechange', selector, zoom.onGestureChange, passive);
426 swiper.$wrapperEl[method]('gestureend', selector, zoom.onGestureEnd, passive);
427 },
428 enableGestures: function enableGestures() {
429 if (this.zoom.gesturesEnabled) return;
430 this.zoom.gesturesEnabled = true;
431 this.zoom.toggleGestures('on');
432 },
433 disableGestures: function disableGestures() {
434 if (!this.zoom.gesturesEnabled) return;
435 this.zoom.gesturesEnabled = false;
436 this.zoom.toggleGestures('off');
437 },
438 // Attach/Detach Events
439 enable: function enable() {
440 var swiper = this;
441 var support = swiper.support;
442 var zoom = swiper.zoom;
443 if (zoom.enabled) return;
444 zoom.enabled = true;
445 var passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? {
446 passive: true,
447 capture: false
448 } : false;
449 var activeListenerWithCapture = support.passiveListener ? {
450 passive: false,
451 capture: true
452 } : true;
453 var slideSelector = "." + swiper.params.slideClass;
454 swiper.zoom.passiveListener = passiveListener;
455 swiper.zoom.slideSelector = slideSelector; // Scale image
456
457 if (support.gestures) {
458 swiper.$wrapperEl.on(swiper.touchEvents.start, swiper.zoom.enableGestures, passiveListener);
459 swiper.$wrapperEl.on(swiper.touchEvents.end, swiper.zoom.disableGestures, passiveListener);
460 } else if (swiper.touchEvents.start === 'touchstart') {
461 swiper.$wrapperEl.on(swiper.touchEvents.start, slideSelector, zoom.onGestureStart, passiveListener);
462 swiper.$wrapperEl.on(swiper.touchEvents.move, slideSelector, zoom.onGestureChange, activeListenerWithCapture);
463 swiper.$wrapperEl.on(swiper.touchEvents.end, slideSelector, zoom.onGestureEnd, passiveListener);
464
465 if (swiper.touchEvents.cancel) {
466 swiper.$wrapperEl.on(swiper.touchEvents.cancel, slideSelector, zoom.onGestureEnd, passiveListener);
467 }
468 } // Move image
469
470
471 swiper.$wrapperEl.on(swiper.touchEvents.move, "." + swiper.params.zoom.containerClass, zoom.onTouchMove, activeListenerWithCapture);
472 },
473 disable: function disable() {
474 var swiper = this;
475 var zoom = swiper.zoom;
476 if (!zoom.enabled) return;
477 var support = swiper.support;
478 swiper.zoom.enabled = false;
479 var passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? {
480 passive: true,
481 capture: false
482 } : false;
483 var activeListenerWithCapture = support.passiveListener ? {
484 passive: false,
485 capture: true
486 } : true;
487 var slideSelector = "." + swiper.params.slideClass; // Scale image
488
489 if (support.gestures) {
490 swiper.$wrapperEl.off(swiper.touchEvents.start, swiper.zoom.enableGestures, passiveListener);
491 swiper.$wrapperEl.off(swiper.touchEvents.end, swiper.zoom.disableGestures, passiveListener);
492 } else if (swiper.touchEvents.start === 'touchstart') {
493 swiper.$wrapperEl.off(swiper.touchEvents.start, slideSelector, zoom.onGestureStart, passiveListener);
494 swiper.$wrapperEl.off(swiper.touchEvents.move, slideSelector, zoom.onGestureChange, activeListenerWithCapture);
495 swiper.$wrapperEl.off(swiper.touchEvents.end, slideSelector, zoom.onGestureEnd, passiveListener);
496
497 if (swiper.touchEvents.cancel) {
498 swiper.$wrapperEl.off(swiper.touchEvents.cancel, slideSelector, zoom.onGestureEnd, passiveListener);
499 }
500 } // Move image
501
502
503 swiper.$wrapperEl.off(swiper.touchEvents.move, "." + swiper.params.zoom.containerClass, zoom.onTouchMove, activeListenerWithCapture);
504 }
505};
506var _default = {
507 name: 'zoom',
508 params: {
509 zoom: {
510 enabled: false,
511 maxRatio: 3,
512 minRatio: 1,
513 toggle: true,
514 containerClass: 'swiper-zoom-container',
515 zoomedSlideClass: 'swiper-slide-zoomed'
516 }
517 },
518 create: function create() {
519 var swiper = this;
520 (0, _utils.bindModuleMethods)(swiper, {
521 zoom: _extends({
522 enabled: false,
523 scale: 1,
524 currentScale: 1,
525 isScaling: false,
526 gesture: {
527 $slideEl: undefined,
528 slideWidth: undefined,
529 slideHeight: undefined,
530 $imageEl: undefined,
531 $imageWrapEl: undefined,
532 maxRatio: 3
533 },
534 image: {
535 isTouched: undefined,
536 isMoved: undefined,
537 currentX: undefined,
538 currentY: undefined,
539 minX: undefined,
540 minY: undefined,
541 maxX: undefined,
542 maxY: undefined,
543 width: undefined,
544 height: undefined,
545 startX: undefined,
546 startY: undefined,
547 touchesStart: {},
548 touchesCurrent: {}
549 },
550 velocity: {
551 x: undefined,
552 y: undefined,
553 prevPositionX: undefined,
554 prevPositionY: undefined,
555 prevTime: undefined
556 }
557 }, Zoom)
558 });
559 var scale = 1;
560 Object.defineProperty(swiper.zoom, 'scale', {
561 get: function get() {
562 return scale;
563 },
564 set: function set(value) {
565 if (scale !== value) {
566 var imageEl = swiper.zoom.gesture.$imageEl ? swiper.zoom.gesture.$imageEl[0] : undefined;
567 var slideEl = swiper.zoom.gesture.$slideEl ? swiper.zoom.gesture.$slideEl[0] : undefined;
568 swiper.emit('zoomChange', value, imageEl, slideEl);
569 }
570
571 scale = value;
572 }
573 });
574 },
575 on: {
576 init: function init(swiper) {
577 if (swiper.params.zoom.enabled) {
578 swiper.zoom.enable();
579 }
580 },
581 destroy: function destroy(swiper) {
582 swiper.zoom.disable();
583 },
584 touchStart: function touchStart(swiper, e) {
585 if (!swiper.zoom.enabled) return;
586 swiper.zoom.onTouchStart(e);
587 },
588 touchEnd: function touchEnd(swiper, e) {
589 if (!swiper.zoom.enabled) return;
590 swiper.zoom.onTouchEnd(e);
591 },
592 doubleTap: function doubleTap(swiper, e) {
593 if (swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) {
594 swiper.zoom.toggle(e);
595 }
596 },
597 transitionEnd: function transitionEnd(swiper) {
598 if (swiper.zoom.enabled && swiper.params.zoom.enabled) {
599 swiper.zoom.onTransitionEnd();
600 }
601 },
602 slideChange: function slideChange(swiper) {
603 if (swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssMode) {
604 swiper.zoom.onTransitionEnd();
605 }
606 }
607 }
608};
609exports.default = _default;
\No newline at end of file