@opentinyvue/vue-image-viewer 2.21.0 → 3.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/mobile.js CHANGED
@@ -3,6 +3,7 @@ import { directive, defineComponent, props, setup } from '@opentinyvue/vue-commo
3
3
  import { iconClose, iconChevronLeft, iconChevronRight, iconZoomOut, iconZoomIn, iconRepeat, iconRefres, iconDel } from '@opentinyvue/vue-icon';
4
4
  import { isObject } from '@opentinyvue/vue-renderless/common/type';
5
5
  import '@opentinyvue/vue-theme-mobile/image-viewer/index.css';
6
+ import { resolveComponent, resolveDirective, openBlock, createBlock, Transition, withCtx, withDirectives, createElementBlock, normalizeStyle, withModifiers, createVNode, createCommentVNode, renderSlot, createElementVNode, toDisplayString, Fragment, normalizeClass, renderList, vShow } from 'vue';
6
7
 
7
8
  var TinyTouch = /* @__PURE__ */ function() {
8
9
  function TinyTouch2(element, tinyBinding, type) {
@@ -100,35 +101,38 @@ var mapDirective = function mapDirective2() {
100
101
  };
101
102
  var touchDeactives = mapDirective();
102
103
 
103
- function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
104
- var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
105
- if (render) {
106
- options.render = render;
107
- options.staticRenderFns = staticRenderFns;
108
- options._compiled = true;
109
- }
110
- var hook;
111
- if (injectStyles) {
112
- hook = injectStyles;
104
+ function _createForOfIteratorHelperLoose(r, e) {
105
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
106
+ if (t) return (t = t.call(r)).next.bind(t);
107
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
108
+ t && (r = t);
109
+ var o = 0;
110
+ return function() {
111
+ return o >= r.length ? { done: true } : { done: false, value: r[o++] };
112
+ };
113
113
  }
114
- if (hook) {
115
- if (options.functional) {
116
- options._injectStyles = hook;
117
- var originalRender = options.render;
118
- options.render = function renderWithStyleInjection(h, context) {
119
- hook.call(context);
120
- return originalRender(h, context);
121
- };
122
- } else {
123
- var existing = options.beforeCreate;
124
- options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
125
- }
114
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
115
+ }
116
+ function _unsupportedIterableToArray(r, a) {
117
+ if (r) {
118
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
119
+ var t = {}.toString.call(r).slice(8, -1);
120
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
126
121
  }
127
- return {
128
- exports: scriptExports,
129
- options
130
- };
131
122
  }
123
+ function _arrayLikeToArray(r, a) {
124
+ (null == a || a > r.length) && (a = r.length);
125
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
126
+ return n;
127
+ }
128
+ var _export_sfc = function _export_sfc2(sfc, props) {
129
+ var target = sfc.__vccOpts || sfc;
130
+ for (var _iterator = _createForOfIteratorHelperLoose(props), _step; !(_step = _iterator()).done; ) {
131
+ var _step$value = _step.value, key = _step$value[0], val = _step$value[1];
132
+ target[key] = val;
133
+ }
134
+ return target;
135
+ };
132
136
 
133
137
  function _extends() {
134
138
  return _extends = Object.assign ? Object.assign.bind() : function(n) {
@@ -139,7 +143,7 @@ function _extends() {
139
143
  return n;
140
144
  }, _extends.apply(null, arguments);
141
145
  }
142
- var __vue2_script = defineComponent({
146
+ var _sfc_main = /* @__PURE__ */ defineComponent({
143
147
  props: [].concat(props, ["urlList", "zIndex", "onSwitch", "onClose", "previewVisible", "closeShow", "arrowShow", "toolShow", "showIndex", "imageFullCurrent", "startPosition", "asyncClose", "deleteButton"]),
144
148
  components: {
145
149
  IconClose: iconClose(),
@@ -161,188 +165,237 @@ var __vue2_script = defineComponent({
161
165
  });
162
166
  }
163
167
  });
164
- var render = function render2() {
165
- var _vm = this;
166
- var _h = _vm.$createElement;
167
- var _c = _vm._self._c || _h;
168
- return _c("transition", {
169
- attrs: {
170
- "name": "viewer-fade"
171
- }
172
- }, [_c("div", {
173
- directives: [{
174
- name: "show",
175
- rawName: "v-show",
176
- value: _vm.state.previewVisible,
177
- expression: "state.previewVisible"
178
- }, {
179
- name: "swipeleft",
180
- rawName: "v-swipeleft",
181
- value: _vm.swipeLeft,
182
- expression: "swipeLeft"
183
- }, {
184
- name: "swiperight",
185
- rawName: "v-swiperight",
186
- value: _vm.swipeRight,
187
- expression: "swipeRight"
188
- }],
189
- ref: "imagePreview",
190
- staticClass: "tiny-mobile-image-viewer__wrapper",
191
- style: {
192
- "z-index": _vm.zIndex
193
- },
194
- on: {
195
- "click": _vm.handleVisible
196
- }
197
- }, [_c("div", {
198
- staticClass: "tiny-mobile-image-viewer__mask"
199
- }), _vm.closeShow ? _c("span", {
200
- staticClass: "tiny-mobile-image-viewer__btn tiny-mobile-image-viewer__close",
201
- on: {
202
- "click": function click($event) {
203
- $event.stopPropagation();
204
- return _vm.handleVisible.apply(null, arguments);
205
- }
206
- }
207
- }, [_c("icon-close", {
208
- staticClass: "tiny-svg-size"
209
- })], 1) : _vm._e(), _vm.showIndex ? _c("div", {
210
- staticClass: "tiny-mobile-image-viewer__btn tiny-mobile-image-viewer__index"
211
- }, [_vm._t("index", function() {
212
- return [_c("span", {
213
- staticClass: "tiny-mobile-image-viewer__index--curren"
214
- }, [_vm._v(_vm._s(_vm.state.index + 1))]), _c("span", [_vm._v("/")]), _c("span", {
215
- staticClass: "tiny-mobile-image-viewer__index--total"
216
- }, [_vm._v(_vm._s(_vm.urlList.length))])];
217
- }, {
218
- "value": _vm.state.index + 1
219
- })], 2) : _vm._e(), !_vm.state.isSingle && _vm.arrowShow ? [_c("span", {
220
- staticClass: "tiny-mobile-image-viewer__btn tiny-mobile-image-viewer__prev",
221
- class: {
222
- "is-disabled": !_vm.state.infinite && _vm.state.isFirst,
223
- "is-arrow-disabled": _vm.state.arrowStyle === "N"
224
- },
225
- on: {
226
- "click": function click($event) {
227
- $event.stopPropagation();
228
- return _vm.swipeRight.apply(null, arguments);
229
- }
230
- }
231
- }, [_c("icon-chevron-left", {
232
- staticClass: "tiny-svg-size"
233
- })], 1), _c("span", {
234
- staticClass: "tiny-mobile-image-viewer__btn tiny-mobile-image-viewer__next",
235
- class: {
236
- "is-disabled": !_vm.state.infinite && _vm.state.isLast,
237
- "is-arrow-disabled": _vm.state.arrowStyle === "Y"
238
- },
239
- on: {
240
- "click": function click($event) {
241
- $event.stopPropagation();
242
- return _vm.swipeLeft.apply(null, arguments);
243
- }
244
- }
245
- }, [_c("icon-chevron-right", {
246
- staticClass: "tiny-svg-size"
247
- })], 1)] : _vm._e(), _vm.toolShow ? _c("div", {
248
- staticClass: "tiny-mobile-image-viewer__btn tiny-mobile-image-viewer__actions"
249
- }, [_c("div", {
250
- staticClass: "tiny-mobile-image-viewer__actions-inner"
251
- }, [_vm._t("tool", function() {
252
- return [_c("icon-zoom-out", {
253
- staticClass: "tiny-svg-size",
254
- on: {
255
- "click": function click($event) {
256
- $event.stopPropagation();
257
- return _vm.handleActions("zoomOut");
258
- }
259
- }
260
- }), _c("icon-zoom-in", {
261
- staticClass: "tiny-svg-size",
262
- on: {
263
- "click": function click($event) {
264
- $event.stopPropagation();
265
- return _vm.handleActions("zoomIn");
266
- }
267
- }
268
- }), _c("icon-repeat", {
269
- staticClass: "tiny-svg-size",
270
- on: {
271
- "click": function click($event) {
272
- $event.stopPropagation();
273
- return _vm.handleActions("anticlocelise");
274
- }
275
- }
276
- }), _c("icon-refres", {
277
- staticClass: "tiny-svg-size",
278
- on: {
279
- "click": function click($event) {
280
- $event.stopPropagation();
281
- return _vm.handleActions("clocelise");
282
- }
283
- }
284
- }), _vm.deleteButton ? _c("icon-del", {
285
- staticClass: "tiny-svg-size",
286
- on: {
287
- "click": function click($event) {
288
- $event.stopPropagation();
289
- return _vm.handleDelete();
290
- }
291
- }
292
- }) : _vm._e()];
293
- })], 2)]) : _vm._e(), _c("div", {
294
- staticClass: "tiny-mobile-image-viewer__canvas"
295
- }, [_c("div", {
296
- staticClass: "tiny-mobile-image-viewer__wrap",
297
- style: {
298
- width: _vm.state.iamgeAllWidth + "px",
299
- "transition-duration": _vm.state.imageTransition + "ms",
300
- transform: "translateX(" + _vm.state.imageTransformSize + "px)"
301
- }
302
- }, _vm._l(_vm.state.urlList, function(url, i) {
303
- return _c("div", {
304
- key: i,
305
- staticClass: "tiny-mobile-image-viewer__item",
306
- style: Object.assign({
307
- width: _vm.state.imageItemWidth + "px"
308
- }, i === _vm.state.index ? _vm.state.imgStyle : "")
309
- }, [_c("div", {
310
- staticClass: "tiny-mobile-image-viewer__detail",
311
- staticStyle: {
312
- "transition-duration": "0.3s"
313
- }
314
- }, [_c("img", {
315
- key: url,
316
- ref: "img_" + i,
317
- refInFor: true,
318
- staticClass: "tiny-mobile-image-viewer__img",
319
- class: {
320
- "is-full-screen": _vm.state.fullScreen
321
- },
322
- attrs: {
323
- "src": url
324
- },
325
- on: {
326
- "load": _vm.handleImgLoad,
327
- "error": _vm.handleImgError,
328
- "mousedown": _vm.handleMouseDown,
329
- "touchstart": _vm.touchstart,
330
- "touchmove": _vm.touchmove,
331
- "touchend": _vm.touchend
332
- }
333
- })])]);
334
- }), 0)])], 2)]);
168
+ var _hoisted_1 = /* @__PURE__ */ createElementVNode(
169
+ "div",
170
+ {
171
+ class: "tiny-mobile-image-viewer__mask"
172
+ },
173
+ null,
174
+ -1
175
+ /* HOISTED */
176
+ );
177
+ var _hoisted_2 = {
178
+ key: 1,
179
+ class: "tiny-mobile-image-viewer__btn tiny-mobile-image-viewer__index"
180
+ };
181
+ var _hoisted_3 = {
182
+ class: "tiny-mobile-image-viewer__index--curren"
183
+ };
184
+ var _hoisted_4 = /* @__PURE__ */ createElementVNode(
185
+ "span",
186
+ null,
187
+ "/",
188
+ -1
189
+ /* HOISTED */
190
+ );
191
+ var _hoisted_5 = {
192
+ class: "tiny-mobile-image-viewer__index--total"
193
+ };
194
+ var _hoisted_6 = {
195
+ key: 3,
196
+ class: "tiny-mobile-image-viewer__btn tiny-mobile-image-viewer__actions"
197
+ };
198
+ var _hoisted_7 = {
199
+ class: "tiny-mobile-image-viewer__actions-inner"
335
200
  };
336
- var staticRenderFns = [];
337
- var __cssModules = {};
338
- var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
339
- function __vue2_injectStyles(context) {
340
- for (var o in __cssModules) {
341
- this[o] = __cssModules[o];
201
+ var _hoisted_8 = {
202
+ class: "tiny-mobile-image-viewer__canvas"
203
+ };
204
+ var _hoisted_9 = {
205
+ class: "tiny-mobile-image-viewer__detail",
206
+ style: {
207
+ "transition-duration": "0.3s"
342
208
  }
209
+ };
210
+ var _hoisted_10 = ["src"];
211
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
212
+ var _component_icon_close = resolveComponent("icon-close");
213
+ var _component_icon_chevron_left = resolveComponent("icon-chevron-left");
214
+ var _component_icon_chevron_right = resolveComponent("icon-chevron-right");
215
+ var _component_icon_zoom_out = resolveComponent("icon-zoom-out");
216
+ var _component_icon_zoom_in = resolveComponent("icon-zoom-in");
217
+ var _component_icon_repeat = resolveComponent("icon-repeat");
218
+ var _component_icon_refres = resolveComponent("icon-refres");
219
+ var _component_icon_del = resolveComponent("icon-del");
220
+ var _directive_swipeleft = resolveDirective("swipeleft");
221
+ var _directive_swiperight = resolveDirective("swiperight");
222
+ return openBlock(), createBlock(Transition, {
223
+ name: "viewer-fade",
224
+ persisted: ""
225
+ }, {
226
+ default: withCtx(function() {
227
+ return [withDirectives((openBlock(), createElementBlock(
228
+ "div",
229
+ {
230
+ class: "tiny-mobile-image-viewer__wrapper",
231
+ ref: "imagePreview",
232
+ style: normalizeStyle({
233
+ "z-index": _ctx.zIndex
234
+ }),
235
+ onClick: _cache[14] || (_cache[14] = function() {
236
+ return _ctx.handleVisible && _ctx.handleVisible.apply(_ctx, arguments);
237
+ })
238
+ },
239
+ [_hoisted_1, _ctx.closeShow ? (openBlock(), createElementBlock("span", {
240
+ key: 0,
241
+ class: "tiny-mobile-image-viewer__btn tiny-mobile-image-viewer__close",
242
+ onClick: _cache[0] || (_cache[0] = withModifiers(function() {
243
+ return _ctx.handleVisible && _ctx.handleVisible.apply(_ctx, arguments);
244
+ }, ["stop"]))
245
+ }, [createVNode(_component_icon_close, {
246
+ class: "tiny-svg-size"
247
+ })])) : createCommentVNode("v-if", true), _ctx.showIndex ? (openBlock(), createElementBlock("div", _hoisted_2, [renderSlot(_ctx.$slots, "index", {
248
+ value: _ctx.state.index + 1
249
+ }, function() {
250
+ return [createElementVNode(
251
+ "span",
252
+ _hoisted_3,
253
+ toDisplayString(_ctx.state.index + 1),
254
+ 1
255
+ /* TEXT */
256
+ ), _hoisted_4, createElementVNode(
257
+ "span",
258
+ _hoisted_5,
259
+ toDisplayString(_ctx.urlList.length),
260
+ 1
261
+ /* TEXT */
262
+ )];
263
+ })])) : createCommentVNode("v-if", true), !_ctx.state.isSingle && _ctx.arrowShow ? (openBlock(), createElementBlock(
264
+ Fragment,
265
+ {
266
+ key: 2
267
+ },
268
+ [createElementVNode(
269
+ "span",
270
+ {
271
+ class: normalizeClass(["tiny-mobile-image-viewer__btn tiny-mobile-image-viewer__prev", {
272
+ "is-disabled": !_ctx.state.infinite && _ctx.state.isFirst,
273
+ "is-arrow-disabled": _ctx.state.arrowStyle === "N"
274
+ }]),
275
+ onClick: _cache[1] || (_cache[1] = withModifiers(function() {
276
+ return _ctx.swipeRight && _ctx.swipeRight.apply(_ctx, arguments);
277
+ }, ["stop"]))
278
+ },
279
+ [createVNode(_component_icon_chevron_left, {
280
+ class: "tiny-svg-size"
281
+ })],
282
+ 2
283
+ /* CLASS */
284
+ ), createElementVNode(
285
+ "span",
286
+ {
287
+ class: normalizeClass(["tiny-mobile-image-viewer__btn tiny-mobile-image-viewer__next", {
288
+ "is-disabled": !_ctx.state.infinite && _ctx.state.isLast,
289
+ "is-arrow-disabled": _ctx.state.arrowStyle === "Y"
290
+ }]),
291
+ onClick: _cache[2] || (_cache[2] = withModifiers(function() {
292
+ return _ctx.swipeLeft && _ctx.swipeLeft.apply(_ctx, arguments);
293
+ }, ["stop"]))
294
+ },
295
+ [createVNode(_component_icon_chevron_right, {
296
+ class: "tiny-svg-size"
297
+ })],
298
+ 2
299
+ /* CLASS */
300
+ )],
301
+ 64
302
+ /* STABLE_FRAGMENT */
303
+ )) : createCommentVNode("v-if", true), _ctx.toolShow ? (openBlock(), createElementBlock("div", _hoisted_6, [createElementVNode("div", _hoisted_7, [renderSlot(_ctx.$slots, "tool", {}, function() {
304
+ return [createVNode(_component_icon_zoom_out, {
305
+ class: "tiny-svg-size",
306
+ onClick: _cache[3] || (_cache[3] = withModifiers(function($event) {
307
+ return _ctx.handleActions("zoomOut");
308
+ }, ["stop"]))
309
+ }), createVNode(_component_icon_zoom_in, {
310
+ class: "tiny-svg-size",
311
+ onClick: _cache[4] || (_cache[4] = withModifiers(function($event) {
312
+ return _ctx.handleActions("zoomIn");
313
+ }, ["stop"]))
314
+ }), createVNode(_component_icon_repeat, {
315
+ class: "tiny-svg-size",
316
+ onClick: _cache[5] || (_cache[5] = withModifiers(function($event) {
317
+ return _ctx.handleActions("anticlocelise");
318
+ }, ["stop"]))
319
+ }), createVNode(_component_icon_refres, {
320
+ class: "tiny-svg-size",
321
+ onClick: _cache[6] || (_cache[6] = withModifiers(function($event) {
322
+ return _ctx.handleActions("clocelise");
323
+ }, ["stop"]))
324
+ }), _ctx.deleteButton ? (openBlock(), createBlock(_component_icon_del, {
325
+ key: 0,
326
+ class: "tiny-svg-size",
327
+ onClick: _cache[7] || (_cache[7] = withModifiers(function($event) {
328
+ return _ctx.handleDelete();
329
+ }, ["stop"]))
330
+ })) : createCommentVNode("v-if", true)];
331
+ })])])) : createCommentVNode("v-if", true), createElementVNode("div", _hoisted_8, [createElementVNode(
332
+ "div",
333
+ {
334
+ class: "tiny-mobile-image-viewer__wrap",
335
+ style: normalizeStyle({
336
+ width: _ctx.state.iamgeAllWidth + "px",
337
+ "transition-duration": _ctx.state.imageTransition + "ms",
338
+ transform: "translateX(" + _ctx.state.imageTransformSize + "px)"
339
+ })
340
+ },
341
+ [(openBlock(true), createElementBlock(
342
+ Fragment,
343
+ null,
344
+ renderList(_ctx.state.urlList, function(url, i) {
345
+ return openBlock(), createElementBlock(
346
+ "div",
347
+ {
348
+ class: "tiny-mobile-image-viewer__item",
349
+ key: i,
350
+ style: normalizeStyle(Object.assign({
351
+ width: _ctx.state.imageItemWidth + "px"
352
+ }, i === _ctx.state.index ? _ctx.state.imgStyle : ""))
353
+ },
354
+ [createElementVNode("div", _hoisted_9, [(openBlock(), createElementBlock("img", {
355
+ ref_for: true,
356
+ ref: "img_" + i,
357
+ class: normalizeClass(["tiny-mobile-image-viewer__img", {
358
+ "is-full-screen": _ctx.state.fullScreen
359
+ }]),
360
+ key: url,
361
+ src: url,
362
+ onLoad: _cache[8] || (_cache[8] = function() {
363
+ return _ctx.handleImgLoad && _ctx.handleImgLoad.apply(_ctx, arguments);
364
+ }),
365
+ onError: _cache[9] || (_cache[9] = function() {
366
+ return _ctx.handleImgError && _ctx.handleImgError.apply(_ctx, arguments);
367
+ }),
368
+ onMousedown: _cache[10] || (_cache[10] = function() {
369
+ return _ctx.handleMouseDown && _ctx.handleMouseDown.apply(_ctx, arguments);
370
+ }),
371
+ onTouchstart: _cache[11] || (_cache[11] = function() {
372
+ return _ctx.touchstart && _ctx.touchstart.apply(_ctx, arguments);
373
+ }),
374
+ onTouchmove: _cache[12] || (_cache[12] = function() {
375
+ return _ctx.touchmove && _ctx.touchmove.apply(_ctx, arguments);
376
+ }),
377
+ onTouchend: _cache[13] || (_cache[13] = function() {
378
+ return _ctx.touchend && _ctx.touchend.apply(_ctx, arguments);
379
+ })
380
+ }, null, 42, _hoisted_10))])],
381
+ 4
382
+ /* STYLE */
383
+ );
384
+ }),
385
+ 128
386
+ /* KEYED_FRAGMENT */
387
+ ))],
388
+ 4
389
+ /* STYLE */
390
+ )])],
391
+ 4
392
+ /* STYLE */
393
+ )), [[vShow, _ctx.state.previewVisible], [_directive_swipeleft, _ctx.swipeLeft], [_directive_swiperight, _ctx.swipeRight]])];
394
+ }),
395
+ _: 3
396
+ /* FORWARDED */
397
+ });
343
398
  }
344
- var mobile = /* @__PURE__ */ function() {
345
- return __component__.exports;
346
- }();
399
+ var mobile = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
347
400
 
348
401
  export { mobile as default };