@opentiny/vue-renderless 3.1.0-alpha.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/action-sheet/index.js +28 -0
- package/action-sheet/vue.js +29 -0
- package/alert/index.js +23 -0
- package/alert/vue.js +37 -0
- package/autocomplete/index.js +175 -0
- package/autocomplete/vue.js +171 -0
- package/avatar/index.js +29 -0
- package/avatar/vue.js +24 -0
- package/badge/index.js +16 -0
- package/badge/vue.js +30 -0
- package/breadcrumb/vue.js +4 -0
- package/breadcrumb-item/vue.js +24 -0
- package/bulletin-board/index.js +21 -0
- package/bulletin-board/vue.js +36 -0
- package/button/index.js +19 -0
- package/button/vue.js +43 -0
- package/button-group/index.js +25 -0
- package/button-group/vue.js +51 -0
- package/calendar/index.js +279 -0
- package/calendar/vue.js +124 -0
- package/card-template/index.js +39 -0
- package/card-template/vue.js +34 -0
- package/carousel/index.js +206 -0
- package/carousel/vue.js +222 -0
- package/carousel-item/index.js +93 -0
- package/carousel-item/vue.js +57 -0
- package/cascader/index.js +511 -0
- package/cascader/vue.js +342 -0
- package/cascader-menu/index.js +41 -0
- package/cascader-menu/vue.js +36 -0
- package/cascader-node/index.js +63 -0
- package/cascader-node/vue.js +62 -0
- package/cascader-panel/index.js +359 -0
- package/cascader-panel/node.js +199 -0
- package/cascader-panel/store.js +80 -0
- package/cascader-panel/vue.js +217 -0
- package/checkbox/index.js +145 -0
- package/checkbox/vue.js +139 -0
- package/checkbox-button/index.js +102 -0
- package/checkbox-button/vue.js +150 -0
- package/checkbox-group/index.js +12 -0
- package/checkbox-group/vue.js +33 -0
- package/col/index.js +132 -0
- package/col/vue.js +34 -0
- package/collapse/index.js +45 -0
- package/collapse/vue.js +35 -0
- package/collapse-item/index.js +38 -0
- package/collapse-item/vue.js +48 -0
- package/common/array.js +120 -0
- package/common/bigInt.js +352 -0
- package/common/browser.js +69 -0
- package/common/dataset/index.js +135 -0
- package/common/date.js +352 -0
- package/common/decimal.js +203 -0
- package/common/deps/ResizeObserver.js +474 -0
- package/common/deps/after-leave.js +25 -0
- package/common/deps/clickoutside.js +61 -0
- package/common/deps/date-util.js +262 -0
- package/common/deps/date.js +308 -0
- package/common/deps/debounce.js +4 -0
- package/common/deps/dom.js +190 -0
- package/common/deps/fullscreen/apis.js +157 -0
- package/common/deps/fullscreen/screenfull.js +106 -0
- package/common/deps/letter-only.js +15 -0
- package/common/deps/memorize.js +149 -0
- package/common/deps/number-only.js +16 -0
- package/common/deps/popper.js +713 -0
- package/common/deps/popup-manager.js +179 -0
- package/common/deps/repeat-click.js +24 -0
- package/common/deps/requestAnimationFrame.js +25 -0
- package/common/deps/resize-event.js +29 -0
- package/common/deps/scroll-into-view.js +29 -0
- package/common/deps/scrollbar-width.js +25 -0
- package/common/deps/throttle.js +34 -0
- package/common/deps/touch.js +33 -0
- package/common/deps/tree-model/node.js +586 -0
- package/common/deps/tree-model/tree-store.js +377 -0
- package/common/deps/tree-model/util.js +14 -0
- package/common/deps/upload-ajax.js +71 -0
- package/common/deps/vue-emitter.js +30 -0
- package/common/deps/vue-popper.js +291 -0
- package/common/deps/vue-popup.js +211 -0
- package/common/event.js +17 -0
- package/common/index.js +288 -0
- package/common/object.js +228 -0
- package/common/runtime.js +52 -0
- package/common/string.js +446 -0
- package/common/type.js +65 -0
- package/common/validate/index.js +6 -0
- package/common/validate/messages.js +68 -0
- package/common/validate/rules/enum.js +8 -0
- package/common/validate/rules/index.js +14 -0
- package/common/validate/rules/pattern.js +16 -0
- package/common/validate/rules/range.js +62 -0
- package/common/validate/rules/required.js +13 -0
- package/common/validate/rules/type.js +110 -0
- package/common/validate/rules/whitespace.js +6 -0
- package/common/validate/schema.js +323 -0
- package/common/validate/util.js +198 -0
- package/common/validate/validations/array.js +25 -0
- package/common/validate/validations/date.js +35 -0
- package/common/validate/validations/enum.js +24 -0
- package/common/validate/validations/float.js +24 -0
- package/common/validate/validations/index.js +42 -0
- package/common/validate/validations/integer.js +24 -0
- package/common/validate/validations/method.js +23 -0
- package/common/validate/validations/number.js +27 -0
- package/common/validate/validations/pattern.js +23 -0
- package/common/validate/validations/required.js +15 -0
- package/common/validate/validations/string.js +29 -0
- package/common/validate/validations/type.js +25 -0
- package/common/xss.js +325 -0
- package/container/index.js +110 -0
- package/container/vue.js +63 -0
- package/credit-card/index.js +107 -0
- package/credit-card/vue.js +117 -0
- package/credit-card-form/index.js +143 -0
- package/credit-card-form/vue.js +150 -0
- package/crop/index.js +297 -0
- package/crop/vue.js +191 -0
- package/date-panel/index.js +584 -0
- package/date-panel/vue.js +319 -0
- package/date-picker/index.js +301 -0
- package/date-picker/vue.js +169 -0
- package/date-range/index.js +463 -0
- package/date-range/vue.js +297 -0
- package/date-table/index.js +457 -0
- package/date-table/vue.js +151 -0
- package/detail-page/index.js +135 -0
- package/detail-page/vue.js +145 -0
- package/dialog-box/index.js +268 -0
- package/dialog-box/vue.js +226 -0
- package/drop-times/index.js +23 -0
- package/drop-times/vue.js +28 -0
- package/dropdown/index.js +259 -0
- package/dropdown/vue.js +107 -0
- package/dropdown-item/index.js +155 -0
- package/dropdown-item/vue.js +124 -0
- package/dropdown-menu/index.js +148 -0
- package/dropdown-menu/vue.js +44 -0
- package/exception/index.js +13 -0
- package/exception/vue.js +25 -0
- package/fall-menu/index.js +121 -0
- package/fall-menu/vue.js +90 -0
- package/file-upload/index.js +1940 -0
- package/file-upload/vue.js +458 -0
- package/floatbar/index.js +10 -0
- package/floatbar/vue.js +17 -0
- package/form/index.js +186 -0
- package/form/vue.js +69 -0
- package/form-item/index.js +364 -0
- package/form-item/vue.js +210 -0
- package/fullscreen/index.js +138 -0
- package/fullscreen/vue.js +77 -0
- package/grid/core/index.js +3 -0
- package/grid/core/interceptor.js +38 -0
- package/grid/core/storeMap.js +19 -0
- package/grid/plugins/export.js +169 -0
- package/grid/plugins/exportExcel.js +749 -0
- package/grid/plugins/header.js +58 -0
- package/grid/plugins/resize.js +82 -0
- package/grid/static/array/arrayEach.js +12 -0
- package/grid/static/array/arrayIndexOf.js +11 -0
- package/grid/static/array/eachTree.js +32 -0
- package/grid/static/array/every.js +2 -0
- package/grid/static/array/filterTree.js +16 -0
- package/grid/static/array/find.js +3 -0
- package/grid/static/array/findTree.js +46 -0
- package/grid/static/array/helperCreateIterateHandle.js +59 -0
- package/grid/static/array/helperCreateTreeFunc.js +18 -0
- package/grid/static/array/includes.js +5 -0
- package/grid/static/array/lastArrayEach.js +6 -0
- package/grid/static/array/map.js +23 -0
- package/grid/static/array/mapTree.js +33 -0
- package/grid/static/array/slice.js +10 -0
- package/grid/static/array/sortBy.js +69 -0
- package/grid/static/array/sum.js +28 -0
- package/grid/static/array/toArray.js +7 -0
- package/grid/static/array/toTreeArray.js +24 -0
- package/grid/static/base/clear.js +44 -0
- package/grid/static/base/clone.js +18 -0
- package/grid/static/base/destructuring.js +18 -0
- package/grid/static/base/each.js +9 -0
- package/grid/static/base/eqNull.js +6 -0
- package/grid/static/base/findIndexOf.js +10 -0
- package/grid/static/base/get.js +42 -0
- package/grid/static/base/has.js +60 -0
- package/grid/static/base/hasOwnProp.js +4 -0
- package/grid/static/base/helperCreateGetObjects.js +26 -0
- package/grid/static/base/helperCreateInInObjectString.js +7 -0
- package/grid/static/base/helperCreateInTypeof.js +6 -0
- package/grid/static/base/helperCreateIndexOf.js +21 -0
- package/grid/static/base/helperCreateiterateIndexOf.js +21 -0
- package/grid/static/base/helperDefaultCompare.js +4 -0
- package/grid/static/base/helperDeleteProperty.js +8 -0
- package/grid/static/base/helperEqualCompare.js +60 -0
- package/grid/static/base/helperGetHGSKeys.js +4 -0
- package/grid/static/base/indexOf.js +3 -0
- package/grid/static/base/isArray.js +3 -0
- package/grid/static/base/isBoolean.js +4 -0
- package/grid/static/base/isDate.js +3 -0
- package/grid/static/base/isEmpty.js +8 -0
- package/grid/static/base/isEqual.js +11 -0
- package/grid/static/base/isFunction.js +4 -0
- package/grid/static/base/isNaN.js +5 -0
- package/grid/static/base/isNull.js +4 -0
- package/grid/static/base/isNumber.js +4 -0
- package/grid/static/base/isObject.js +5 -0
- package/grid/static/base/isPlainObject.js +2 -0
- package/grid/static/base/isRegExp.js +3 -0
- package/grid/static/base/isSet.js +5 -0
- package/grid/static/base/isString.js +4 -0
- package/grid/static/base/isUndefined.js +4 -0
- package/grid/static/base/keys.js +3 -0
- package/grid/static/base/lastEach.js +9 -0
- package/grid/static/base/remove.js +44 -0
- package/grid/static/base/set.js +43 -0
- package/grid/static/base/toJSONString.js +4 -0
- package/grid/static/base/toStringJSON.js +13 -0
- package/grid/static/base/uniqueId.js +5 -0
- package/grid/static/browse/browse.js +54 -0
- package/grid/static/function/property.js +7 -0
- package/grid/static/function/throttle.js +43 -0
- package/grid/static/index.js +55 -0
- package/grid/static/number/helperCreateToNumber.js +12 -0
- package/grid/static/number/toNumber.js +3 -0
- package/grid/static/object/assign.js +41 -0
- package/grid/static/object/extend.js +3 -0
- package/grid/static/object/lastObjectEach.js +8 -0
- package/grid/static/object/objectEach.js +11 -0
- package/grid/static/object/objectMap.js +20 -0
- package/grid/static/object/values.js +9 -0
- package/grid/static/static/staticDocument.js +4 -0
- package/grid/static/static/staticHGKeyRE.js +2 -0
- package/grid/static/static/staticParseInt.js +2 -0
- package/grid/static/static/staticStrUndefined.js +2 -0
- package/grid/static/static/staticWindow.js +4 -0
- package/grid/static/string/template.js +12 -0
- package/grid/static/string/toString.js +12 -0
- package/grid/utils/column.js +72 -0
- package/grid/utils/common.js +155 -0
- package/grid/utils/dom.js +213 -0
- package/grid/utils/event.js +40 -0
- package/grid/utils/index.js +5 -0
- package/image/index.js +187 -0
- package/image/vue.js +142 -0
- package/image-viewer/index.js +469 -0
- package/image-viewer/vue.js +243 -0
- package/input/index.js +319 -0
- package/input/vue.js +319 -0
- package/ip-address/index.js +370 -0
- package/ip-address/vue.js +185 -0
- package/layout/vue.js +4 -0
- package/link/index.js +10 -0
- package/link/vue.js +26 -0
- package/link-menu/index.js +146 -0
- package/link-menu/vue.js +138 -0
- package/list/index.js +13 -0
- package/list/vue.js +17 -0
- package/loading/index.js +29 -0
- package/loading/vue.js +28 -0
- package/milestone/index.js +92 -0
- package/milestone/vue.js +31 -0
- package/mini-picker/index.js +227 -0
- package/mini-picker/vue.js +142 -0
- package/modal/index.js +866 -0
- package/modal/vue.js +130 -0
- package/month-range/index.js +169 -0
- package/month-range/vue.js +104 -0
- package/month-table/index.js +232 -0
- package/month-table/vue.js +72 -0
- package/nav-menu/index.js +457 -0
- package/nav-menu/vue.js +187 -0
- package/notify/index.js +91 -0
- package/notify/vue.js +67 -0
- package/numeric/index.js +419 -0
- package/numeric/vue.js +218 -0
- package/option/index.js +79 -0
- package/option/vue.js +219 -0
- package/option-group/index.js +18 -0
- package/option-group/vue.js +37 -0
- package/package.json +179 -0
- package/pager-item/index.js +122 -0
- package/pager-item/vue.js +52 -0
- package/panel/index.js +30 -0
- package/panel/vue.js +26 -0
- package/picker/index.js +1039 -0
- package/picker/timezone.js +974 -0
- package/picker/vue.js +415 -0
- package/picker-column/index.js +261 -0
- package/picker-column/vue.js +163 -0
- package/pop-upload/index.js +324 -0
- package/pop-upload/vue.js +292 -0
- package/popeditor/index.js +884 -0
- package/popeditor/vue.js +368 -0
- package/popover/index.js +203 -0
- package/popover/vue.js +174 -0
- package/popup/index.js +139 -0
- package/popup/vue.js +129 -0
- package/progress/index.js +174 -0
- package/progress/vue.js +118 -0
- package/pull-refresh/index.js +104 -0
- package/pull-refresh/vue.js +64 -0
- package/radio/index.js +83 -0
- package/radio/vue.js +99 -0
- package/radio-button/index.js +58 -0
- package/radio-button/vue.js +70 -0
- package/radio-group/index.js +51 -0
- package/radio-group/vue.js +34 -0
- package/rate/index.js +254 -0
- package/rate/vue.js +158 -0
- package/row/index.js +19 -0
- package/row/vue.js +24 -0
- package/scroll-text/index.js +24 -0
- package/scroll-text/vue.js +31 -0
- package/scrollbar/index.js +127 -0
- package/scrollbar/vue-bar.js +49 -0
- package/scrollbar/vue.js +43 -0
- package/search/index.js +110 -0
- package/search/vue.js +110 -0
- package/select/index.js +1766 -0
- package/select/vue.js +693 -0
- package/select-dropdown/index.js +23 -0
- package/select-dropdown/vue.js +122 -0
- package/slide-bar/index.js +94 -0
- package/slide-bar/vue.js +58 -0
- package/slider/index.js +434 -0
- package/slider/vue.js +172 -0
- package/split/index.js +122 -0
- package/split/vue.js +131 -0
- package/steps/vue.js +4 -0
- package/switch/index.js +45 -0
- package/switch/vue.js +62 -0
- package/tab-bar/index.js +51 -0
- package/tab-bar/vue.js +16 -0
- package/tab-dropdown/index.js +11 -0
- package/tab-dropdown/vue.js +17 -0
- package/tab-item/index.js +37 -0
- package/tab-item/vue.js +49 -0
- package/tab-nav/index.js +247 -0
- package/tab-nav/vue.js +106 -0
- package/tabbar/index.js +32 -0
- package/tabbar/vue.js +54 -0
- package/tabbar-item/index.js +55 -0
- package/tabbar-item/vue.js +53 -0
- package/table/index.js +111 -0
- package/table/vue.js +66 -0
- package/tabs/index.js +174 -0
- package/tabs/vue.js +141 -0
- package/tag/index.js +14 -0
- package/tag/vue.js +13 -0
- package/tall-storage/index.js +161 -0
- package/tall-storage/vue-storage-box.js +25 -0
- package/tall-storage/vue.js +38 -0
- package/text-popup/index.js +75 -0
- package/text-popup/vue.js +64 -0
- package/time/index.js +121 -0
- package/time/vue.js +124 -0
- package/time-line/index.js +60 -0
- package/time-line/vue.js +49 -0
- package/time-panel/index.js +189 -0
- package/time-panel/scrollIntoView.js +23 -0
- package/time-panel/vue.js +110 -0
- package/time-range/index.js +199 -0
- package/time-range/vue.js +129 -0
- package/time-spinner/index.js +175 -0
- package/time-spinner/vue.js +122 -0
- package/toggle-menu/index.js +104 -0
- package/toggle-menu/vue.js +74 -0
- package/tooltip/index.js +171 -0
- package/tooltip/vue.js +133 -0
- package/top-box/index.js +81 -0
- package/top-box/vue.js +77 -0
- package/transfer/index.js +296 -0
- package/transfer/vue.js +138 -0
- package/transfer-panel/index.js +364 -0
- package/transfer-panel/vue.js +258 -0
- package/tree/index.js +642 -0
- package/tree/vue.js +268 -0
- package/tree-menu/index.js +124 -0
- package/tree-menu/vue.js +60 -0
- package/tree-node/index.js +271 -0
- package/tree-node/vue.js +211 -0
- package/upload/index.js +324 -0
- package/upload/vue.js +93 -0
- package/upload-dragger/index.js +50 -0
- package/upload-dragger/vue.js +27 -0
- package/upload-list/index.js +55 -0
- package/upload-list/vue.js +48 -0
- package/user-contact/index.js +13 -0
- package/user-contact/vue.js +20 -0
- package/user-head/index.js +71 -0
- package/user-head/vue.js +47 -0
- package/wizard/index.js +123 -0
- package/wizard/vue.js +45 -0
- package/year-table/index.js +40 -0
- package/year-table/vue.js +23 -0
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { on, off } from '@opentiny/vue-renderless/common/deps/dom';
|
|
5
|
+
import { KEY_CODE } from '@opentiny/vue-renderless/common';
|
|
6
|
+
import PopupManager from '@opentiny/vue-renderless/common/deps/popup-manager';
|
|
7
|
+
var isFirefox = function isFirefox() {
|
|
8
|
+
return !!window.navigator.userAgent.match(/firefox/i);
|
|
9
|
+
};
|
|
10
|
+
var mousewheelEventName = isFirefox() ? 'DOMMouseScroll' : 'mousewheel';
|
|
11
|
+
export var rafThrottle = function rafThrottle(fn) {
|
|
12
|
+
var locked = false;
|
|
13
|
+
return function () {
|
|
14
|
+
var _this = this;
|
|
15
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
+
args[_key] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
if (locked) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
locked = true;
|
|
22
|
+
window.requestAnimationFrame(function () {
|
|
23
|
+
fn.apply(_this, args);
|
|
24
|
+
locked = false;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export var hide = function hide(_ref) {
|
|
29
|
+
var props = _ref.props,
|
|
30
|
+
api = _ref.api;
|
|
31
|
+
return function () {
|
|
32
|
+
api.deviceSupportUninstall();
|
|
33
|
+
props.onClose();
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export var deviceSupportInstall = function deviceSupportInstall(_ref2) {
|
|
37
|
+
var state = _ref2.state,
|
|
38
|
+
api = _ref2.api;
|
|
39
|
+
return function () {
|
|
40
|
+
state._keyDownHandler = rafThrottle(function (event) {
|
|
41
|
+
var keyCode = event.keyCode;
|
|
42
|
+
switch (keyCode) {
|
|
43
|
+
case KEY_CODE.Escape:
|
|
44
|
+
api.hide();
|
|
45
|
+
break;
|
|
46
|
+
case KEY_CODE.Space:
|
|
47
|
+
api.toggleMode();
|
|
48
|
+
break;
|
|
49
|
+
case KEY_CODE.ArrowLeft:
|
|
50
|
+
api.prev();
|
|
51
|
+
break;
|
|
52
|
+
case KEY_CODE.ArrowUp:
|
|
53
|
+
api.handleActions('zoomIn');
|
|
54
|
+
break;
|
|
55
|
+
case KEY_CODE.ArrowRight:
|
|
56
|
+
api.next();
|
|
57
|
+
break;
|
|
58
|
+
case KEY_CODE.ArrowDown:
|
|
59
|
+
api.handleActions('zoomOut');
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
state._mouseWheelHandler = rafThrottle(function (event) {
|
|
66
|
+
var delta = event.wheelDelta ? event.wheelDelta : -event.detail;
|
|
67
|
+
if (delta > 0) {
|
|
68
|
+
api.handleActions('zoomIn', {
|
|
69
|
+
zoomRate: 0.015,
|
|
70
|
+
enableTransition: false
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
api.handleActions('zoomOut', {
|
|
74
|
+
zoomRate: 0.015,
|
|
75
|
+
enableTransition: false
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
on(document, 'keydown', state._keyDownHandler);
|
|
80
|
+
on(document, mousewheelEventName, state._mouseWheelHandler);
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export var deviceSupportUninstall = function deviceSupportUninstall(state) {
|
|
84
|
+
return function () {
|
|
85
|
+
off(document, 'keydown', state._keyDownHandler);
|
|
86
|
+
off(document, mousewheelEventName, state._mouseWheelHandler);
|
|
87
|
+
state._keyDownHandler = null;
|
|
88
|
+
state._mouseWheelHandler = null;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export var handleImgLoad = function handleImgLoad(state) {
|
|
92
|
+
return function () {
|
|
93
|
+
return state.loading = false;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
export var handleImgError = function handleImgError(_ref3) {
|
|
97
|
+
var state = _ref3.state,
|
|
98
|
+
t = _ref3.t;
|
|
99
|
+
return function (event) {
|
|
100
|
+
state.loading = false;
|
|
101
|
+
event.target.alt = t('ui.imageViewer.loadErrorAlt');
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export var handleMouseDown = function handleMouseDown(state) {
|
|
105
|
+
return function (event) {
|
|
106
|
+
if (state.loading || event.button !== 0) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
var _state$transform = state.transform,
|
|
110
|
+
offsetX = _state$transform.offsetX,
|
|
111
|
+
offsetY = _state$transform.offsetY;
|
|
112
|
+
var startX = event.pageX;
|
|
113
|
+
var startY = event.pageY;
|
|
114
|
+
state._dragHandler = rafThrottle(function (event) {
|
|
115
|
+
state.transform.offsetX = offsetX + event.pageX - startX;
|
|
116
|
+
state.transform.offsetY = offsetY + event.pageY - startY;
|
|
117
|
+
});
|
|
118
|
+
on(document, 'mousemove', state._dragHandler);
|
|
119
|
+
on(document, 'mouseup', function () {
|
|
120
|
+
return off(document, 'mousemove', state._dragHandler);
|
|
121
|
+
});
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
export var reset = function reset(state) {
|
|
126
|
+
return function () {
|
|
127
|
+
return state.transform = {
|
|
128
|
+
scale: 1,
|
|
129
|
+
deg: 0,
|
|
130
|
+
offsetX: 0,
|
|
131
|
+
offsetY: 0,
|
|
132
|
+
enableTransition: false
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
export var toggleMode = function toggleMode(_ref4) {
|
|
137
|
+
var state = _ref4.state,
|
|
138
|
+
constants = _ref4.constants,
|
|
139
|
+
api = _ref4.api;
|
|
140
|
+
return function () {
|
|
141
|
+
if (state.loading) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
var MODE = constants.MODE;
|
|
145
|
+
var modeNames = Object.keys(MODE);
|
|
146
|
+
var modeValues = [];
|
|
147
|
+
modeNames.forEach(function (key) {
|
|
148
|
+
modeValues.push(MODE[key]);
|
|
149
|
+
});
|
|
150
|
+
var index = -1;
|
|
151
|
+
modeValues.forEach(function (item, inx) {
|
|
152
|
+
if (item.name === state.mode.name) {
|
|
153
|
+
index = inx;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
var nextIndex = (index + 1) % modeNames.length;
|
|
157
|
+
state.mode = MODE[modeNames[nextIndex]];
|
|
158
|
+
api.reset();
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
export var prev = function prev(_ref5) {
|
|
162
|
+
var state = _ref5.state,
|
|
163
|
+
props = _ref5.props;
|
|
164
|
+
return function () {
|
|
165
|
+
if (state.isFirst && !state.infinite) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
var len = props.urlList.length;
|
|
169
|
+
state.index = (state.index - 1 + len) % len;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
export var next = function next(_ref6) {
|
|
173
|
+
var state = _ref6.state,
|
|
174
|
+
props = _ref6.props;
|
|
175
|
+
return function () {
|
|
176
|
+
if (state.isLast && !state.infinite) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
var len = props.urlList.length;
|
|
180
|
+
state.index = (state.index + 1) % len;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
export var handleActions = function handleActions(state) {
|
|
184
|
+
return function (action) {
|
|
185
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
186
|
+
if (state.loading) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
var _zoomRate$rotateDeg$e = _objectSpread({
|
|
190
|
+
zoomRate: 0.2,
|
|
191
|
+
rotateDeg: 90,
|
|
192
|
+
enableTransition: true
|
|
193
|
+
}, options),
|
|
194
|
+
zoomRate = _zoomRate$rotateDeg$e.zoomRate,
|
|
195
|
+
rotateDeg = _zoomRate$rotateDeg$e.rotateDeg,
|
|
196
|
+
enableTransition = _zoomRate$rotateDeg$e.enableTransition;
|
|
197
|
+
var transform = state.transform;
|
|
198
|
+
if (action === 'zoomOut') {
|
|
199
|
+
if (transform.scale > 0.2) {
|
|
200
|
+
transform.scale = parseFloat((transform.scale - zoomRate).toFixed(3));
|
|
201
|
+
}
|
|
202
|
+
} else if (action === 'zoomIn') {
|
|
203
|
+
transform.scale = parseFloat((transform.scale + zoomRate).toFixed(3));
|
|
204
|
+
} else if (action === 'clocelise') {
|
|
205
|
+
transform.deg += rotateDeg;
|
|
206
|
+
} else if (action === 'anticlocelise') {
|
|
207
|
+
transform.deg -= rotateDeg;
|
|
208
|
+
}
|
|
209
|
+
transform.enableTransition = enableTransition;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
export var computedIsSingle = function computedIsSingle(props) {
|
|
213
|
+
return function () {
|
|
214
|
+
return props.urlList.length <= 1;
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
export var computedIsFirst = function computedIsFirst(state) {
|
|
218
|
+
return function () {
|
|
219
|
+
return state.index === 0;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
export var computedIsLast = function computedIsLast(_ref7) {
|
|
223
|
+
var state = _ref7.state,
|
|
224
|
+
props = _ref7.props;
|
|
225
|
+
return function () {
|
|
226
|
+
return state.index === props.urlList.length - 1;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
export var computedCurrentImg = function computedCurrentImg(_ref8) {
|
|
230
|
+
var state = _ref8.state,
|
|
231
|
+
props = _ref8.props;
|
|
232
|
+
return function () {
|
|
233
|
+
return props.urlList[state.index];
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
export var computedImgStyle = function computedImgStyle(_ref9) {
|
|
237
|
+
var state = _ref9.state,
|
|
238
|
+
constants = _ref9.constants;
|
|
239
|
+
return function () {
|
|
240
|
+
var _state$transform2 = state.transform,
|
|
241
|
+
offsetX = _state$transform2.offsetX,
|
|
242
|
+
offsetY = _state$transform2.offsetY,
|
|
243
|
+
scale = _state$transform2.scale,
|
|
244
|
+
deg = _state$transform2.deg,
|
|
245
|
+
enableTransition = _state$transform2.enableTransition;
|
|
246
|
+
var transition = enableTransition ? 'transform .3s' : '';
|
|
247
|
+
var style = {
|
|
248
|
+
transform: "scale(".concat(scale, ") rotate(").concat(deg, "deg)"),
|
|
249
|
+
transition: transition,
|
|
250
|
+
'margin-top': "".concat(offsetY, "px"),
|
|
251
|
+
'margin-left': "".concat(offsetX, "px")
|
|
252
|
+
};
|
|
253
|
+
if (JSON.stringify(state.mode) === JSON.stringify(constants.MODE.CONTAIN)) {
|
|
254
|
+
style.maxWidth = style.maxHeight = '100%';
|
|
255
|
+
}
|
|
256
|
+
return style;
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
export var watchVisible = function watchVisible(state) {
|
|
260
|
+
return function (value) {
|
|
261
|
+
return state.previewVisible = value;
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
export var handleVisible = function handleVisible(_ref10) {
|
|
265
|
+
var state = _ref10.state,
|
|
266
|
+
emit = _ref10.emit,
|
|
267
|
+
props = _ref10.props;
|
|
268
|
+
return function () {
|
|
269
|
+
state.transform.scale = 1;
|
|
270
|
+
state.transform.deg = 0;
|
|
271
|
+
setTimeout(function () {
|
|
272
|
+
if (props.startPosition !== 0) {
|
|
273
|
+
state.index = (props.startPosition - 1 + state.urlList.length) % state.urlList.length;
|
|
274
|
+
state.imageTransform = state.index * state.imageItemWidth;
|
|
275
|
+
state.imageTransformSize = -state.index * state.imageItemWidth;
|
|
276
|
+
} else {
|
|
277
|
+
state.index = 0;
|
|
278
|
+
state.imageTransform = state.index * state.imageItemWidth;
|
|
279
|
+
state.imageTransformSize = -state.index * state.imageItemWidth;
|
|
280
|
+
}
|
|
281
|
+
}, 300);
|
|
282
|
+
emit('update:preview-visible', false);
|
|
283
|
+
emit('close', state.index, state.urlList[state.index]);
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
export var getImageWidth = function getImageWidth(_ref11) {
|
|
287
|
+
var state = _ref11.state,
|
|
288
|
+
parent = _ref11.parent,
|
|
289
|
+
props = _ref11.props;
|
|
290
|
+
return function () {
|
|
291
|
+
var imageW = 0;
|
|
292
|
+
var len = state.urlList.length;
|
|
293
|
+
imageW = parent.$el.querySelector('.tiny-mobile-image-viewer__canvas').offsetWidth;
|
|
294
|
+
state.imageList = parent.$el.querySelectorAll('.tiny-mobile-image-viewer__item');
|
|
295
|
+
state.imageItemWidth = imageW;
|
|
296
|
+
state.iamgeAllWidth = state.urlList.length * imageW;
|
|
297
|
+
if (props.startPosition !== 0) {
|
|
298
|
+
state.index = props.startPosition;
|
|
299
|
+
state.imageTransition = 0;
|
|
300
|
+
var transformX = state.index * state.imageItemWidth;
|
|
301
|
+
state.imageTransform = transformX;
|
|
302
|
+
state.imageTransformSize = -transformX;
|
|
303
|
+
}
|
|
304
|
+
if (state.index === 0 && props.deleteButton && state["delete"]) {
|
|
305
|
+
state.imageTransition = 0;
|
|
306
|
+
var _transformX = state.index * state.imageItemWidth;
|
|
307
|
+
state.imageTransform = _transformX;
|
|
308
|
+
state.imageTransformSize = -_transformX;
|
|
309
|
+
}
|
|
310
|
+
setTimeout(function () {
|
|
311
|
+
state.imageTransition = 300;
|
|
312
|
+
}, 0);
|
|
313
|
+
if (props.startPosition === 0) {
|
|
314
|
+
state.arrowStyle = 'N';
|
|
315
|
+
}
|
|
316
|
+
if (props.startPosition === len - 1) {
|
|
317
|
+
state.arrowStyle = 'Y';
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
export var swipeLeft = function swipeLeft(_ref12) {
|
|
322
|
+
var state = _ref12.state,
|
|
323
|
+
emit = _ref12.emit;
|
|
324
|
+
return function () {
|
|
325
|
+
if (state.isLast && !state.infinite) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
var len = state.urlList.length;
|
|
329
|
+
if (state.index >= state.urlList.length - 2) {
|
|
330
|
+
state.arrowStyle = 'Y';
|
|
331
|
+
} else {
|
|
332
|
+
state.arrowStyle = null;
|
|
333
|
+
}
|
|
334
|
+
if (state.imageTransform === state.iamgeAllWidth) {
|
|
335
|
+
state.imageTransformSize = state.imageTransform = 0;
|
|
336
|
+
state.imageList[0].style.transform = null;
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
if (state.imageTransform == state.iamgeAllWidth - state.imageItemWidth && state.index == state.urlList.length - 1) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
state.index = (state.index + 1) % len;
|
|
343
|
+
var transformX = state.index * state.imageItemWidth;
|
|
344
|
+
state.imageTransform = transformX;
|
|
345
|
+
state.imageTransformSize = -transformX;
|
|
346
|
+
emit('change', state.index, state.urlList[state.index]);
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
export var swipeRight = function swipeRight(_ref13) {
|
|
350
|
+
var state = _ref13.state,
|
|
351
|
+
emit = _ref13.emit;
|
|
352
|
+
return function () {
|
|
353
|
+
if (state.isFirst && !state.infinite) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
var len = state.urlList.length;
|
|
357
|
+
if (state.index <= 1) {
|
|
358
|
+
state.arrowStyle = 'N';
|
|
359
|
+
} else {
|
|
360
|
+
state.arrowStyle = null;
|
|
361
|
+
}
|
|
362
|
+
if (state.imageTransform == 0 && state.index == 0) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
state.index = (state.index - 1 + len) % len;
|
|
366
|
+
var transformX = state.index * state.imageItemWidth;
|
|
367
|
+
state.imageTransform = transformX;
|
|
368
|
+
state.imageTransformSize = -transformX;
|
|
369
|
+
emit('change', state.index, state.urlList[state.index]);
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
export var handleDelete = function handleDelete(_ref14) {
|
|
373
|
+
var api = _ref14.api,
|
|
374
|
+
emit = _ref14.emit,
|
|
375
|
+
state = _ref14.state;
|
|
376
|
+
return function () {
|
|
377
|
+
if (state.urlList.length <= 1) {
|
|
378
|
+
state["delete"] = false;
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
state["delete"] = true;
|
|
382
|
+
var currenIndex = state.index;
|
|
383
|
+
var urlList = state.urlList;
|
|
384
|
+
urlList.splice(currenIndex, 1);
|
|
385
|
+
state.urlList = urlList;
|
|
386
|
+
state.index = 0;
|
|
387
|
+
api.getImageWidth();
|
|
388
|
+
emit('newImageList', state.urlList, currenIndex);
|
|
389
|
+
};
|
|
390
|
+
};
|
|
391
|
+
var preventDefault = function preventDefault(event, isStopPropagation) {
|
|
392
|
+
if (typeof event.cancelable !== 'boolean' || event.cancelable) {
|
|
393
|
+
event.preventDefault();
|
|
394
|
+
}
|
|
395
|
+
if (isStopPropagation) {
|
|
396
|
+
event.stopPropagation();
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
export var touchstart = function touchstart(state) {
|
|
400
|
+
return function (e) {
|
|
401
|
+
var touches = e.touches;
|
|
402
|
+
var events = touches[0];
|
|
403
|
+
var events2 = touches[1];
|
|
404
|
+
preventDefault(e);
|
|
405
|
+
state.pageX = events.pageX;
|
|
406
|
+
state.pageY = events.pageY;
|
|
407
|
+
state.moveable = true;
|
|
408
|
+
if (events2) {
|
|
409
|
+
state.pageX2 = events2.pageX;
|
|
410
|
+
state.pageY2 = events2.pageY;
|
|
411
|
+
}
|
|
412
|
+
state.originScale = state.scale || 1;
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
export var touchmove = function touchmove(state) {
|
|
416
|
+
return function (event) {
|
|
417
|
+
if (!state.moveable) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
preventDefault(event);
|
|
421
|
+
var touches = event.touches;
|
|
422
|
+
var events = touches[0];
|
|
423
|
+
var events2 = touches[1];
|
|
424
|
+
if (events2) {
|
|
425
|
+
if (!state.pageX2) {
|
|
426
|
+
state.pageX2 = events2.pageX;
|
|
427
|
+
}
|
|
428
|
+
if (!state.pageY2) {
|
|
429
|
+
state.pageY2 = events2.pageY;
|
|
430
|
+
}
|
|
431
|
+
var getDistance = function getDistance(start, stop) {
|
|
432
|
+
return Math.hypot(stop.x - start.x, stop.y - start.y);
|
|
433
|
+
};
|
|
434
|
+
var zoom = getDistance({
|
|
435
|
+
x: events.pageX,
|
|
436
|
+
y: events.pageY
|
|
437
|
+
}, {
|
|
438
|
+
x: events2.pageX,
|
|
439
|
+
y: events2.pageY
|
|
440
|
+
}) / getDistance({
|
|
441
|
+
x: state.pageX,
|
|
442
|
+
y: state.pageY
|
|
443
|
+
}, {
|
|
444
|
+
x: state.pageX2,
|
|
445
|
+
y: state.pageY2
|
|
446
|
+
});
|
|
447
|
+
var newScale = state.originScale * zoom;
|
|
448
|
+
if (newScale > 3) {
|
|
449
|
+
newScale = 3;
|
|
450
|
+
}
|
|
451
|
+
state.scale = newScale;
|
|
452
|
+
state.transform.scale = newScale;
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
};
|
|
456
|
+
export var touchend = function touchend(state) {
|
|
457
|
+
return function () {
|
|
458
|
+
state.moveable = false;
|
|
459
|
+
state.pageX2 = 0;
|
|
460
|
+
state.pageY2 = 0;
|
|
461
|
+
};
|
|
462
|
+
};
|
|
463
|
+
export var computeZIndex = function computeZIndex(_ref15) {
|
|
464
|
+
var constants = _ref15.constants,
|
|
465
|
+
props = _ref15.props;
|
|
466
|
+
return function () {
|
|
467
|
+
return props.zIndex === constants.DEFAULT_POPPER_ZINDEX || props.zIndex < 1 ? PopupManager.nextZIndex() : props.zIndex;
|
|
468
|
+
};
|
|
469
|
+
};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { computedIsSingle, watchVisible, computedIsFirst, computedIsLast, computedCurrentImg, computedImgStyle, hide, deviceSupportInstall, deviceSupportUninstall, handleImgLoad, handleImgError, handleMouseDown, reset, toggleMode, prev, next, handleActions, handleVisible, getImageWidth, swipeLeft, swipeRight, handleDelete, touchstart, touchmove, touchend, computeZIndex } from './index';
|
|
2
|
+
export var api = ['state', 'zIndex', 'touchstart', 'touchmove', 'touchend', 'urlList', 'hide', 'prev', 'next', 'handleActions', 'toggleMode', 'handleImgLoad', 'handleImgError', 'handleMouseDown', 'handleVisible', 'swipeLeft', 'swipeRight', 'handleDelete'];
|
|
3
|
+
var initState = function initState(_ref) {
|
|
4
|
+
var reactive = _ref.reactive,
|
|
5
|
+
computed = _ref.computed,
|
|
6
|
+
api = _ref.api,
|
|
7
|
+
mode = _ref.mode,
|
|
8
|
+
props = _ref.props,
|
|
9
|
+
constants = _ref.constants;
|
|
10
|
+
var state = reactive({
|
|
11
|
+
index: mode == 'pc' ? 0 : props.startPosition,
|
|
12
|
+
isShow: false,
|
|
13
|
+
infinite: true,
|
|
14
|
+
loading: false,
|
|
15
|
+
transform: {
|
|
16
|
+
scale: 1,
|
|
17
|
+
deg: 0,
|
|
18
|
+
offsetX: 0,
|
|
19
|
+
offsetY: 0,
|
|
20
|
+
objfit: 'contain',
|
|
21
|
+
enableTransition: false
|
|
22
|
+
},
|
|
23
|
+
urlList: props.urlList,
|
|
24
|
+
mode: constants.MODE.CONTAIN,
|
|
25
|
+
previewVisible: props.previewVisible,
|
|
26
|
+
fullScreen: props.imageFullCurrent,
|
|
27
|
+
hammer: null,
|
|
28
|
+
imageItemWidth: 0,
|
|
29
|
+
imageAllWidth: 0,
|
|
30
|
+
imageTransform: 0,
|
|
31
|
+
imageTransformSize: 0,
|
|
32
|
+
imageTransition: 300,
|
|
33
|
+
imageList: null,
|
|
34
|
+
arrowStyle: null,
|
|
35
|
+
"delete": false,
|
|
36
|
+
isLast: computed(function () {
|
|
37
|
+
return api.computedIsLast();
|
|
38
|
+
}),
|
|
39
|
+
isFirst: computed(function () {
|
|
40
|
+
return api.computedIsFirst();
|
|
41
|
+
}),
|
|
42
|
+
isSingle: computed(function () {
|
|
43
|
+
return api.computedIsSingle();
|
|
44
|
+
}),
|
|
45
|
+
imgStyle: computed(function () {
|
|
46
|
+
return api.computedImgStyle();
|
|
47
|
+
}),
|
|
48
|
+
currentImg: computed(function () {
|
|
49
|
+
return api.computedCurrentImg();
|
|
50
|
+
}),
|
|
51
|
+
zIndex: computed(function () {
|
|
52
|
+
return api.computeZIndex();
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
return state;
|
|
56
|
+
};
|
|
57
|
+
var initApi = function initApi(_ref2) {
|
|
58
|
+
var api = _ref2.api,
|
|
59
|
+
state = _ref2.state,
|
|
60
|
+
props = _ref2.props,
|
|
61
|
+
parent = _ref2.parent,
|
|
62
|
+
nextTick = _ref2.nextTick,
|
|
63
|
+
emit = _ref2.emit,
|
|
64
|
+
t = _ref2.t,
|
|
65
|
+
constants = _ref2.constants;
|
|
66
|
+
Object.assign(api, {
|
|
67
|
+
state: state,
|
|
68
|
+
touchstart: touchstart(state),
|
|
69
|
+
touchmove: touchmove(state),
|
|
70
|
+
touchend: touchend(state),
|
|
71
|
+
reset: reset(state),
|
|
72
|
+
prev: prev({
|
|
73
|
+
state: state,
|
|
74
|
+
props: props
|
|
75
|
+
}),
|
|
76
|
+
next: next({
|
|
77
|
+
state: state,
|
|
78
|
+
props: props
|
|
79
|
+
}),
|
|
80
|
+
getImageWidth: getImageWidth({
|
|
81
|
+
state: state,
|
|
82
|
+
parent: parent,
|
|
83
|
+
props: props,
|
|
84
|
+
nextTick: nextTick
|
|
85
|
+
}),
|
|
86
|
+
handleVisible: handleVisible({
|
|
87
|
+
state: state,
|
|
88
|
+
emit: emit,
|
|
89
|
+
props: props
|
|
90
|
+
}),
|
|
91
|
+
handleActions: handleActions(state),
|
|
92
|
+
handleImgLoad: handleImgLoad(state),
|
|
93
|
+
handleMouseDown: handleMouseDown(state),
|
|
94
|
+
computedIsFirst: computedIsFirst(state),
|
|
95
|
+
computedIsSingle: computedIsSingle(props),
|
|
96
|
+
handleImgError: handleImgError({
|
|
97
|
+
state: state,
|
|
98
|
+
t: t
|
|
99
|
+
}),
|
|
100
|
+
computedIsLast: computedIsLast({
|
|
101
|
+
state: state,
|
|
102
|
+
props: props
|
|
103
|
+
}),
|
|
104
|
+
watchVisible: watchVisible(state),
|
|
105
|
+
deviceSupportUninstall: deviceSupportUninstall(state),
|
|
106
|
+
computedCurrentImg: computedCurrentImg({
|
|
107
|
+
state: state,
|
|
108
|
+
props: props
|
|
109
|
+
}),
|
|
110
|
+
computedImgStyle: computedImgStyle({
|
|
111
|
+
state: state,
|
|
112
|
+
constants: constants
|
|
113
|
+
}),
|
|
114
|
+
computeZIndex: computeZIndex({
|
|
115
|
+
constants: constants,
|
|
116
|
+
props: props
|
|
117
|
+
}),
|
|
118
|
+
hide: hide({
|
|
119
|
+
props: props,
|
|
120
|
+
api: api
|
|
121
|
+
}),
|
|
122
|
+
deviceSupportInstall: deviceSupportInstall({
|
|
123
|
+
state: state,
|
|
124
|
+
api: api
|
|
125
|
+
}),
|
|
126
|
+
toggleMode: toggleMode({
|
|
127
|
+
state: state,
|
|
128
|
+
constants: constants,
|
|
129
|
+
api: api
|
|
130
|
+
}),
|
|
131
|
+
swipeRight: swipeRight({
|
|
132
|
+
api: api,
|
|
133
|
+
state: state,
|
|
134
|
+
emit: emit
|
|
135
|
+
}),
|
|
136
|
+
swipeLeft: swipeLeft({
|
|
137
|
+
api: api,
|
|
138
|
+
state: state,
|
|
139
|
+
emit: emit
|
|
140
|
+
}),
|
|
141
|
+
handleDelete: handleDelete({
|
|
142
|
+
api: api,
|
|
143
|
+
state: state,
|
|
144
|
+
emit: emit
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
var initWatch = function initWatch(_ref3) {
|
|
149
|
+
var watch = _ref3.watch,
|
|
150
|
+
state = _ref3.state,
|
|
151
|
+
api = _ref3.api,
|
|
152
|
+
props = _ref3.props,
|
|
153
|
+
nextTick = _ref3.nextTick,
|
|
154
|
+
vm = _ref3.vm;
|
|
155
|
+
watch(function () {
|
|
156
|
+
return state.index;
|
|
157
|
+
}, function (value) {
|
|
158
|
+
api.reset();
|
|
159
|
+
props.onSwitch(value);
|
|
160
|
+
}, {
|
|
161
|
+
immediate: true
|
|
162
|
+
});
|
|
163
|
+
watch(function () {
|
|
164
|
+
return props.previewVisible;
|
|
165
|
+
}, function (value) {
|
|
166
|
+
api.watchVisible(value);
|
|
167
|
+
if (props.previewVisible) {
|
|
168
|
+
nextTick(function () {
|
|
169
|
+
state.urlList = props.urlList;
|
|
170
|
+
api.getImageWidth();
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}, {
|
|
174
|
+
immediate: true
|
|
175
|
+
});
|
|
176
|
+
watch(function () {
|
|
177
|
+
return state.currentImg;
|
|
178
|
+
}, function (value) {
|
|
179
|
+
nextTick(function () {
|
|
180
|
+
var index = state.urlList.indexOf(value);
|
|
181
|
+
var imageIns = vm.$refs["img_".concat(index)];
|
|
182
|
+
if (Array.isArray(imageIns)) {
|
|
183
|
+
imageIns = imageIns[0];
|
|
184
|
+
}
|
|
185
|
+
if (imageIns) {
|
|
186
|
+
state.loading = !imageIns.complete;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}, {
|
|
190
|
+
immediate: true
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
export var renderless = function renderless(props, _ref4, _ref5) {
|
|
194
|
+
var computed = _ref4.computed,
|
|
195
|
+
onMounted = _ref4.onMounted,
|
|
196
|
+
onUpdated = _ref4.onUpdated,
|
|
197
|
+
reactive = _ref4.reactive,
|
|
198
|
+
watch = _ref4.watch;
|
|
199
|
+
var t = _ref5.t,
|
|
200
|
+
parent = _ref5.parent,
|
|
201
|
+
nextTick = _ref5.nextTick,
|
|
202
|
+
emit = _ref5.emit,
|
|
203
|
+
constants = _ref5.constants,
|
|
204
|
+
vm = _ref5.vm,
|
|
205
|
+
mode = _ref5.mode;
|
|
206
|
+
var api = {};
|
|
207
|
+
var state = initState({
|
|
208
|
+
reactive: reactive,
|
|
209
|
+
computed: computed,
|
|
210
|
+
api: api,
|
|
211
|
+
mode: mode,
|
|
212
|
+
props: props,
|
|
213
|
+
constants: constants
|
|
214
|
+
});
|
|
215
|
+
initApi({
|
|
216
|
+
api: api,
|
|
217
|
+
state: state,
|
|
218
|
+
props: props,
|
|
219
|
+
parent: parent,
|
|
220
|
+
nextTick: nextTick,
|
|
221
|
+
emit: emit,
|
|
222
|
+
t: t,
|
|
223
|
+
constants: constants
|
|
224
|
+
});
|
|
225
|
+
initWatch({
|
|
226
|
+
watch: watch,
|
|
227
|
+
state: state,
|
|
228
|
+
api: api,
|
|
229
|
+
props: props,
|
|
230
|
+
nextTick: nextTick,
|
|
231
|
+
vm: vm
|
|
232
|
+
});
|
|
233
|
+
onMounted(api.deviceSupportInstall);
|
|
234
|
+
onUpdated(function () {
|
|
235
|
+
if (props.asyncClose) {
|
|
236
|
+
setTimeout(function () {
|
|
237
|
+
state.previewVisible = false;
|
|
238
|
+
emit('update:preview-visible', false);
|
|
239
|
+
}, 3000);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
return api;
|
|
243
|
+
};
|