@web-atoms/web-controls 2.6.5 → 2.6.7
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/dist/html-editor/InlineHtmlEditor.d.ts +1 -1
- package/dist/html-editor/InlineHtmlEditor.d.ts.map +1 -1
- package/dist/html-editor/InlineHtmlEditor.js +2 -2
- package/dist/html-editor/InlineHtmlEditor.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist-esm/ArrayLike.js +14 -12
- package/dist-esm/DataAttributes.js +18 -19
- package/dist-esm/Focusable.js +10 -11
- package/dist-esm/ModuleFiles.js +43 -42
- package/dist-esm/NumberFormats.js +60 -56
- package/dist-esm/PageNavigator.js +28 -30
- package/dist-esm/animations/Animations.js +36 -33
- package/dist-esm/basic/AtomChips.js +312 -305
- package/dist-esm/basic/AtomRepeater.js +1070 -1035
- package/dist-esm/basic/AtomSuggestions.js +97 -107
- package/dist-esm/basic/AttachedPopup.js +0 -1
- package/dist-esm/basic/Button.js +45 -19
- package/dist-esm/basic/ButtonBar.js +84 -64
- package/dist-esm/basic/Calendar.js +211 -203
- package/dist-esm/basic/CheckBoxList.js +90 -70
- package/dist-esm/basic/Checkbox.js +16 -8
- package/dist-esm/basic/Chip.js +36 -12
- package/dist-esm/basic/ComboBox.js +47 -51
- package/dist-esm/basic/DataGrid.js +258 -252
- package/dist-esm/basic/DateField.js +149 -127
- package/dist-esm/basic/DropDown.js +91 -103
- package/dist-esm/basic/DropDownInput.js +78 -106
- package/dist-esm/basic/Editable.js +82 -77
- package/dist-esm/basic/Expander.js +104 -86
- package/dist-esm/basic/FilesDragDrop.js +84 -80
- package/dist-esm/basic/Form.js +80 -52
- package/dist-esm/basic/FormField.js +164 -106
- package/dist-esm/basic/IElement.js +1 -2
- package/dist-esm/basic/InlinePopup.js +263 -234
- package/dist-esm/basic/InlinePopupButton.js +99 -88
- package/dist-esm/basic/InlinePopupControl.js +24 -23
- package/dist-esm/basic/ItemPath.js +59 -60
- package/dist-esm/basic/LimitedText.js +49 -38
- package/dist-esm/basic/ListRepeater.js +13 -14
- package/dist-esm/basic/MaskedInput.js +37 -29
- package/dist-esm/basic/MaskedInputDiv.js +55 -48
- package/dist-esm/basic/MergeNode.js +64 -35
- package/dist-esm/basic/PasswordBox.js +32 -17
- package/dist-esm/basic/PinchZoomView.js +221 -199
- package/dist-esm/basic/PopupButton.js +39 -16
- package/dist-esm/basic/PopupMenu.js +3 -4
- package/dist-esm/basic/RadioButtonList.js +35 -25
- package/dist-esm/basic/RefreshLock.js +41 -42
- package/dist-esm/basic/Resizable.js +43 -33
- package/dist-esm/basic/Select.js +72 -65
- package/dist-esm/basic/SortByButton.js +41 -31
- package/dist-esm/basic/Swipe.js +91 -84
- package/dist-esm/basic/Switch.js +22 -8
- package/dist-esm/basic/TableRepeater.js +29 -33
- package/dist-esm/basic/TimeEditor.js +97 -52
- package/dist-esm/basic/TitleEditor.js +115 -95
- package/dist-esm/basic/ToggleButtonBar.js +21 -22
- package/dist-esm/basic/Tooltip.js +49 -47
- package/dist-esm/basic/TypeWriter.js +45 -42
- package/dist-esm/basic/UploadEvent.js +211 -178
- package/dist-esm/basic/ZoomView.js +229 -198
- package/dist-esm/basic/combineClasses.js +2 -3
- package/dist-esm/basic/elements/AtomPopover.js +270 -253
- package/dist-esm/basic/elements/getContainingBlock.js +34 -35
- package/dist-esm/basic/elements/relativeRect.js +40 -21
- package/dist-esm/desktop-app/DesktopApp.js +65 -80
- package/dist-esm/desktop-app/MobileDesktopApp.js +20 -23
- package/dist-esm/html-editor/AtomHtmlEditor.js +243 -268
- package/dist-esm/html-editor/HtmlEditorCommands.js +6 -4
- package/dist-esm/html-editor/InlineHtmlEditor.d.ts +1 -1
- package/dist-esm/html-editor/InlineHtmlEditor.d.ts.map +1 -1
- package/dist-esm/html-editor/InlineHtmlEditor.js +175 -167
- package/dist-esm/html-editor/InlineHtmlEditor.js.map +1 -1
- package/dist-esm/html-editor/RangeEditor.js +49 -51
- package/dist-esm/html-editor/commands/AddImage.js +40 -35
- package/dist-esm/html-editor/commands/AddLink.js +56 -54
- package/dist-esm/html-editor/commands/Align.js +24 -7
- package/dist-esm/html-editor/commands/AttachFile.js +23 -13
- package/dist-esm/html-editor/commands/AttachImage.js +35 -25
- package/dist-esm/html-editor/commands/Bold.js +10 -11
- package/dist-esm/html-editor/commands/ChangeColor.js +31 -107
- package/dist-esm/html-editor/commands/ChangeFont.js +42 -42
- package/dist-esm/html-editor/commands/ChangeFontSize.js +15 -5
- package/dist-esm/html-editor/commands/Command.js +34 -16
- package/dist-esm/html-editor/commands/CommandButton.js +51 -32
- package/dist-esm/html-editor/commands/Headings.js +25 -9
- package/dist-esm/html-editor/commands/HorizontalRule.js +9 -10
- package/dist-esm/html-editor/commands/HtmlCommands.js +160 -65
- package/dist-esm/html-editor/commands/IndentLess.js +10 -11
- package/dist-esm/html-editor/commands/IndentMore.js +10 -11
- package/dist-esm/html-editor/commands/Italic.js +10 -11
- package/dist-esm/html-editor/commands/NumberedList.js +10 -11
- package/dist-esm/html-editor/commands/Quote.js +10 -11
- package/dist-esm/html-editor/commands/RemoveFormat.js +10 -11
- package/dist-esm/html-editor/commands/Separator.js +5 -4
- package/dist-esm/html-editor/commands/Source.js +29 -25
- package/dist-esm/html-editor/commands/StrikeThrough.js +10 -11
- package/dist-esm/html-editor/commands/Toolbar.js +6 -4
- package/dist-esm/html-editor/commands/Underline.js +10 -11
- package/dist-esm/html-editor/commands/Unlink.js +10 -9
- package/dist-esm/html-editor/commands/UnorderedList.js +10 -11
- package/dist-esm/mobile-app/BottomPopup.js +137 -148
- package/dist-esm/mobile-app/MasterDetailPage.js +153 -152
- package/dist-esm/mobile-app/MobileApp.js +577 -569
- package/dist-esm/player/AtomVideoPlayer.js +316 -270
- package/dist-esm/player/TrackProgress.js +11 -7
- package/dist-esm/player/input-range-style.js +97 -98
- package/dist-esm/tests/app-test/AppTestApp.js +12 -15
- package/dist-esm/tests/app-test/AppTestApp.pack.js +54 -0
- package/dist-esm/tests/app-test/commands/AppCommands.js +14 -11
- package/dist-esm/tests/app-test/drawer/AppDrawer.js +4 -6
- package/dist-esm/tests/app-test/model/model.js +1 -2
- package/dist-esm/tests/app-test/pages/detail/DetailPage.js +21 -15
- package/dist-esm/tests/app-test/pages/home/HomePage.js +7 -8
- package/dist-esm/tests/app-test/pages/list/ListPage.js +79 -62
- package/dist-esm/tests/basic/PopupTest.js +9 -7
- package/dist-esm/tests/basic/TimeEditorTest.js +5 -9
- package/dist-esm/tests/basic/TimeEditorTest.pack.js +39 -0
- package/dist-esm/tests/basic/TimerTest.js +27 -37
- package/dist-esm/tests/basic/TimerTest.pack.js +40 -0
- package/dist-esm/tests/basic/basic-form/BasicForm.js +47 -27
- package/dist-esm/tests/basic/basic-form/BasicForm.pack.js +44 -0
- package/dist-esm/tests/basic/calendar/BasicCalendarTest.js +5 -9
- package/dist-esm/tests/basic/calendar/BasicCalendarTest.pack.js +53 -0
- package/dist-esm/tests/basic/chips/ChipsTest.js +25 -15
- package/dist-esm/tests/basic/chips/ChipsTest.pack.js +56 -0
- package/dist-esm/tests/basic/data-grid/DataGridTest.js +55 -60
- package/dist-esm/tests/basic/data-grid/DataGridTest.pack.js +58 -0
- package/dist-esm/tests/basic/date/DateFieldTest.js +21 -96
- package/dist-esm/tests/basic/date/DateFieldTest.pack.js +57 -0
- package/dist-esm/tests/basic/drop-down/DropDownTest.js +25 -19
- package/dist-esm/tests/basic/drop-down/DropDownTest.pack.js +52 -0
- package/dist-esm/tests/basic/drop-down-input/DropDownTest.js +32 -32
- package/dist-esm/tests/basic/drop-down-input/DropDownTest.pack.js +54 -0
- package/dist-esm/tests/basic/expander/ExpanderMenuTest.js +20 -14
- package/dist-esm/tests/basic/expander/ExpanderMenuTest.pack.js +38 -0
- package/dist-esm/tests/basic/expander/ExpanderTest.js +11 -12
- package/dist-esm/tests/basic/expander/ExpanderTest.pack.js +38 -0
- package/dist-esm/tests/basic/form2/Form2Test.js +26 -24
- package/dist-esm/tests/basic/form2/Form2Test.pack.js +46 -0
- package/dist-esm/tests/basic/limited-text/LimitedTextTest.js +14 -11
- package/dist-esm/tests/basic/limited-text/LimitedTextTest.pack.js +38 -0
- package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.js +14 -14
- package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.pack.js +38 -0
- package/dist-esm/tests/basic/repeater/DragDropRepater.js +30 -12
- package/dist-esm/tests/basic/repeater/DragDropRepater.pack.js +51 -0
- package/dist-esm/tests/basic/repeater/RepeaterTest.js +45 -35
- package/dist-esm/tests/basic/repeater/RepeaterTest.pack.js +52 -0
- package/dist-esm/tests/basic/swipe/SwipeTest.js +13 -13
- package/dist-esm/tests/basic/swipe/SwipeTest.pack.js +52 -0
- package/dist-esm/tests/basic/switch-test/SwitchTest.js +8 -10
- package/dist-esm/tests/basic/switch-test/SwitchTest.pack.js +38 -0
- package/dist-esm/tests/basic/title-editor/TitleEditorTest.js +8 -9
- package/dist-esm/tests/basic/title-editor/TitleEditorTest.pack.js +38 -0
- package/dist-esm/tests/basic/tooltip/TooltipTest.js +30 -24
- package/dist-esm/tests/basic/tooltip/TooltipTest.pack.js +52 -0
- package/dist-esm/tests/basic/typewriter/TypeWriter.js +10 -9
- package/dist-esm/tests/basic/typewriter/TypeWriter.pack.js +39 -0
- package/dist-esm/tests/basic/video/AtomVideoTest.js +13 -10
- package/dist-esm/tests/basic/video/AtomVideoTest.pack.js +38 -0
- package/dist-esm/tests/basic/zoom/ZoomViewTest.js +13 -13
- package/dist-esm/tests/basic/zoom/ZoomViewTest.pack.js +38 -0
- package/dist-esm/tests/check-box-list/CheckBoxListSample.js +13 -12
- package/dist-esm/tests/check-box-list/CheckBoxListSample.pack.js +52 -0
- package/dist-esm/tests/data-grid/GridTestViewModel.js +203 -227
- package/dist-esm/tests/form/CustomHelp.js +6 -9
- package/dist-esm/tests/form/FormViewModel.js +21 -28
- package/dist-esm/tests/html-editor/HtmlEditorTest.js +7 -37
- package/dist-esm/tests/html-editor/HtmlEditorTest.pack.js +83 -0
- package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.js +9 -38
- package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.pack.js +85 -0
- package/dist-esm/tests/mask/MaskedInputTest.js +11 -12
- package/dist-esm/tests/mask/MaskedInputTest.pack.js +38 -0
- package/dist-esm/tests/mobile-app/DesktopAppTest.js +8 -9
- package/dist-esm/tests/mobile-app/DesktopAppTest.pack.js +60 -0
- package/dist-esm/tests/mobile-app/MobileAppTest.js +64 -53
- package/dist-esm/tests/mobile-app/MobileAppTest.pack.js +55 -0
- package/dist-esm/tests/pop-over/PopOverTest.js +37 -77
- package/dist-esm/tests/switch/SwitchTest.js +9 -8
- package/dist-esm/tests/toggle-view/ToggleViewTest.js +15 -22
- package/dist-esm/tests/toggle-view/ToggleViewTest.pack.js +45 -0
- package/dist-esm/toggle-view/AtomToggleView.js +77 -73
- package/dist-esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/html-editor/InlineHtmlEditor.tsx +1 -1
|
@@ -3,215 +3,246 @@ import Bind from "@web-atoms/core/dist/core/Bind.js";
|
|
|
3
3
|
import { BindableProperty } from "@web-atoms/core/dist/core/BindableProperty.js";
|
|
4
4
|
import XNode from "@web-atoms/core/dist/core/XNode.js";
|
|
5
5
|
import { AtomControl } from "@web-atoms/core/dist/web/controls/AtomControl.js";
|
|
6
|
-
import
|
|
7
|
-
const center =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
x: touch.clientX,
|
|
12
|
-
y: touch.clientY
|
|
13
|
-
};
|
|
14
|
-
}
|
|
6
|
+
ESMPack.installStyleSheet(import.meta.resolve("./styles/zoom-view.global.css"));
|
|
7
|
+
const center = ev => {
|
|
8
|
+
const touch = ev.touches[0];
|
|
9
|
+
if (touch) {
|
|
15
10
|
return {
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
x: touch.clientX,
|
|
12
|
+
y: touch.clientY
|
|
18
13
|
};
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 0
|
|
18
|
+
};
|
|
19
19
|
};
|
|
20
20
|
const distance = (first, second) => {
|
|
21
|
-
|
|
21
|
+
return Math.hypot(first.pageX - second.pageX, first.pageY - second.pageY);
|
|
22
22
|
};
|
|
23
|
-
const findLargestDistance =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
const findLargestDistance = touches => {
|
|
24
|
+
let pair = null;
|
|
25
|
+
for (let i = 0; i < touches.length; i++) {
|
|
26
|
+
const t1 = touches[i];
|
|
27
|
+
for (let j = i + 1; j < touches.length; j++) {
|
|
28
|
+
const t2 = touches[j];
|
|
29
|
+
const distance = Math.hypot(t1.pageX - t2.pageX, t1.pageY - t2.pageY);
|
|
30
|
+
if (pair === null) {
|
|
31
|
+
pair = {
|
|
32
|
+
t1,
|
|
33
|
+
t2,
|
|
34
|
+
distance
|
|
35
|
+
};
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (pair.distance < distance) {
|
|
39
|
+
pair = {
|
|
40
|
+
t1,
|
|
41
|
+
t2,
|
|
42
|
+
distance
|
|
43
|
+
};
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
|
-
|
|
46
|
+
}
|
|
47
|
+
return pair;
|
|
40
48
|
};
|
|
41
49
|
export default class ZoomView extends AtomControl {
|
|
42
|
-
|
|
43
|
-
|
|
50
|
+
preCreate() {
|
|
51
|
+
this.element.title = "Use mouse wheel to zoom";
|
|
52
|
+
this.loading = false;
|
|
53
|
+
this.zoom = {
|
|
54
|
+
scale: 0,
|
|
55
|
+
anchorX: 0,
|
|
56
|
+
anchorY: 0,
|
|
57
|
+
x: 0,
|
|
58
|
+
y: 0
|
|
59
|
+
};
|
|
60
|
+
this.element.setAttribute("data-zoom-view", "zoom-view");
|
|
61
|
+
this.element.draggable = false;
|
|
62
|
+
this.render(XNode.create("div", null, XNode.create("div", {
|
|
63
|
+
class: "scroll"
|
|
64
|
+
}, XNode.create("img", {
|
|
65
|
+
class: "image-container",
|
|
66
|
+
src: Bind.oneWay(() => this.getSource(this.source)),
|
|
67
|
+
"style-opacity": Bind.oneWay(() => this.loading ? "0.3" : "1"),
|
|
68
|
+
"event-load": () => {
|
|
44
69
|
this.loading = false;
|
|
45
|
-
this.zoom
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (previousDistance === void 0) {
|
|
83
|
-
previousDistance = newScale;
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (previousDistance === newScale) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
anchorX = ((first.clientX + second.clientX) / 2) - rect.left;
|
|
90
|
-
anchorY = ((first.clientY + second.clientY) / 2) - rect.top;
|
|
91
|
-
scale += newScale - previousDistance;
|
|
92
|
-
previousDistance = newScale;
|
|
93
|
-
this.updateZoom({
|
|
94
|
-
anchorX,
|
|
95
|
-
anchorY,
|
|
96
|
-
x,
|
|
97
|
-
y,
|
|
98
|
-
scale
|
|
99
|
-
});
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
touchEndDisposable ??= this.bindEvent(scrollView, "touchend", (ev) => {
|
|
104
|
-
touchMoveDisposable?.dispose();
|
|
105
|
-
touchEndDisposable?.dispose();
|
|
106
|
-
touchMoveDisposable = undefined;
|
|
107
|
-
touchEndDisposable = undefined;
|
|
108
|
-
previousDistance = undefined;
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
let mouseMoveDisposable;
|
|
112
|
-
let mouseUpDisposable;
|
|
113
|
-
this.bindEvent(scrollView, "dragstart", (ev) => {
|
|
114
|
-
ev.preventDefault();
|
|
115
|
-
ev.stopImmediatePropagation();
|
|
116
|
-
});
|
|
117
|
-
this.bindEvent(scrollView, "mousedown", (ev) => {
|
|
118
|
-
this.element.dataset.state = "grabbing";
|
|
119
|
-
previous = {
|
|
120
|
-
x: ev.clientX,
|
|
121
|
-
y: ev.clientY
|
|
122
|
-
};
|
|
123
|
-
mouseMoveDisposable ??= this.bindEvent(scrollView, "mousemove", (e) => {
|
|
124
|
-
e.preventDefault();
|
|
125
|
-
e.stopImmediatePropagation?.();
|
|
126
|
-
const cp = { x: e.clientX, y: e.clientY };
|
|
127
|
-
const diffX = previous.x - cp.x;
|
|
128
|
-
const diffY = previous.y - cp.y;
|
|
129
|
-
previous = cp;
|
|
130
|
-
this.scrollDiv.scrollBy(diffX, diffY);
|
|
131
|
-
});
|
|
132
|
-
mouseUpDisposable ??= this.bindEvent(scrollView, "mouseup", (e) => {
|
|
133
|
-
e.preventDefault();
|
|
134
|
-
e.stopImmediatePropagation?.();
|
|
135
|
-
this.element.dataset.state = "";
|
|
136
|
-
previous = null;
|
|
137
|
-
mouseMoveDisposable.dispose();
|
|
138
|
-
mouseUpDisposable.dispose();
|
|
139
|
-
mouseMoveDisposable = undefined;
|
|
140
|
-
mouseUpDisposable = undefined;
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
this.bindEvent(scrollView, "wheel", (ev) => {
|
|
144
|
-
ev.preventDefault();
|
|
145
|
-
ev.stopImmediatePropagation?.();
|
|
146
|
-
const newScale = this.zoom.scale - (ev.deltaY < 0 ? -50 : 50);
|
|
147
|
-
const anchorX = ev.offsetX;
|
|
148
|
-
const anchorY = ev.offsetY;
|
|
149
|
-
const { x, y } = this.zoom;
|
|
150
|
-
this.updateZoom({
|
|
151
|
-
anchorX,
|
|
152
|
-
anchorY,
|
|
153
|
-
x,
|
|
154
|
-
y,
|
|
155
|
-
scale: newScale < 0 ? 0 : newScale
|
|
156
|
-
});
|
|
157
|
-
}, undefined, {
|
|
158
|
-
passive: false
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
getSource(text) {
|
|
162
|
-
if (text) {
|
|
163
|
-
this.loading = true;
|
|
164
|
-
}
|
|
165
|
-
return text;
|
|
166
|
-
}
|
|
167
|
-
updateZoom(zoom = {
|
|
168
|
-
x: 0,
|
|
169
|
-
y: 0,
|
|
170
|
-
anchorX: 0,
|
|
171
|
-
anchorY: 0,
|
|
172
|
-
scale: 0
|
|
173
|
-
}) {
|
|
174
|
-
const { anchorX, anchorY, x, y } = zoom;
|
|
175
|
-
let { scale } = zoom;
|
|
176
|
-
this.zoom = zoom;
|
|
177
|
-
const image = this.image;
|
|
178
|
-
if (!image.naturalHeight) {
|
|
70
|
+
this.updateZoom(this.zoom);
|
|
71
|
+
}
|
|
72
|
+
})), XNode.create("i", {
|
|
73
|
+
class: Bind.oneWay(() => this.loading ? "spinner fa-duotone fa-spinner fa-spin" : "hide")
|
|
74
|
+
}), XNode.create("i", {
|
|
75
|
+
"event-click": () => this.updateZoom(),
|
|
76
|
+
class: Bind.oneWay(() => this.zoom.scale ? "scale" : "hide"),
|
|
77
|
+
title: "Display entire image"
|
|
78
|
+
})));
|
|
79
|
+
this.scrollDiv = this.element.firstElementChild;
|
|
80
|
+
this.imageContainer = this.scrollDiv.firstElementChild;
|
|
81
|
+
this.image = this.imageContainer;
|
|
82
|
+
const scrollView = this.element;
|
|
83
|
+
let previous;
|
|
84
|
+
let touchMoveDisposable;
|
|
85
|
+
let touchEndDisposable;
|
|
86
|
+
this.bindEvent(scrollView, "touchstart", evs => {
|
|
87
|
+
previous = center(evs);
|
|
88
|
+
let previousDistance = undefined;
|
|
89
|
+
touchMoveDisposable ??= this.bindEvent(scrollView, "touchmove", ev => {
|
|
90
|
+
let {
|
|
91
|
+
x,
|
|
92
|
+
y,
|
|
93
|
+
anchorX,
|
|
94
|
+
anchorY,
|
|
95
|
+
scale
|
|
96
|
+
} = this.zoom;
|
|
97
|
+
if (ev.touches.length > 1) {
|
|
98
|
+
ev.preventDefault();
|
|
99
|
+
ev.stopImmediatePropagation();
|
|
100
|
+
const rect = this.element.getBoundingClientRect();
|
|
101
|
+
const ld = findLargestDistance(ev.touches);
|
|
102
|
+
const first = ld.t1;
|
|
103
|
+
const second = ld.t2;
|
|
104
|
+
const newScale = ld.distance;
|
|
105
|
+
if (previousDistance === void 0) {
|
|
106
|
+
previousDistance = newScale;
|
|
179
107
|
return;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const s = maxHeight
|
|
183
|
-
? this.element.clientWidth / image.naturalWidth
|
|
184
|
-
: this.element.clientHeight / image.naturalHeight;
|
|
185
|
-
if (scale <= 0) {
|
|
186
|
-
scale = 0;
|
|
187
|
-
}
|
|
188
|
-
const { clientWidth, clientHeight } = this.element;
|
|
189
|
-
if (scale <= 0) {
|
|
190
|
-
this.element.scrollTo(0, 0);
|
|
191
|
-
this.imageContainer.style.transform = ``;
|
|
108
|
+
}
|
|
109
|
+
if (previousDistance === newScale) {
|
|
192
110
|
return;
|
|
111
|
+
}
|
|
112
|
+
anchorX = (first.clientX + second.clientX) / 2 - rect.left;
|
|
113
|
+
anchorY = (first.clientY + second.clientY) / 2 - rect.top;
|
|
114
|
+
scale += newScale - previousDistance;
|
|
115
|
+
previousDistance = newScale;
|
|
116
|
+
this.updateZoom({
|
|
117
|
+
anchorX,
|
|
118
|
+
anchorY,
|
|
119
|
+
x,
|
|
120
|
+
y,
|
|
121
|
+
scale
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
193
124
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
125
|
+
});
|
|
126
|
+
touchEndDisposable ??= this.bindEvent(scrollView, "touchend", ev => {
|
|
127
|
+
touchMoveDisposable?.dispose();
|
|
128
|
+
touchEndDisposable?.dispose();
|
|
129
|
+
touchMoveDisposable = undefined;
|
|
130
|
+
touchEndDisposable = undefined;
|
|
131
|
+
previousDistance = undefined;
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
let mouseMoveDisposable;
|
|
135
|
+
let mouseUpDisposable;
|
|
136
|
+
this.bindEvent(scrollView, "dragstart", ev => {
|
|
137
|
+
ev.preventDefault();
|
|
138
|
+
ev.stopImmediatePropagation();
|
|
139
|
+
});
|
|
140
|
+
this.bindEvent(scrollView, "mousedown", ev => {
|
|
141
|
+
this.element.dataset.state = "grabbing";
|
|
142
|
+
previous = {
|
|
143
|
+
x: ev.clientX,
|
|
144
|
+
y: ev.clientY
|
|
145
|
+
};
|
|
146
|
+
mouseMoveDisposable ??= this.bindEvent(scrollView, "mousemove", e => {
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
e.stopImmediatePropagation?.();
|
|
149
|
+
const cp = {
|
|
150
|
+
x: e.clientX,
|
|
151
|
+
y: e.clientY
|
|
152
|
+
};
|
|
153
|
+
const diffX = previous.x - cp.x;
|
|
154
|
+
const diffY = previous.y - cp.y;
|
|
155
|
+
previous = cp;
|
|
156
|
+
this.scrollDiv.scrollBy(diffX, diffY);
|
|
157
|
+
});
|
|
158
|
+
mouseUpDisposable ??= this.bindEvent(scrollView, "mouseup", e => {
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
e.stopImmediatePropagation?.();
|
|
161
|
+
this.element.dataset.state = "";
|
|
162
|
+
previous = null;
|
|
163
|
+
mouseMoveDisposable.dispose();
|
|
164
|
+
mouseUpDisposable.dispose();
|
|
165
|
+
mouseMoveDisposable = undefined;
|
|
166
|
+
mouseUpDisposable = undefined;
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
this.bindEvent(scrollView, "wheel", ev => {
|
|
170
|
+
ev.preventDefault();
|
|
171
|
+
ev.stopImmediatePropagation?.();
|
|
172
|
+
const newScale = this.zoom.scale - (ev.deltaY < 0 ? -50 : 50);
|
|
173
|
+
const anchorX = ev.offsetX;
|
|
174
|
+
const anchorY = ev.offsetY;
|
|
175
|
+
const {
|
|
176
|
+
x,
|
|
177
|
+
y
|
|
178
|
+
} = this.zoom;
|
|
179
|
+
this.updateZoom({
|
|
180
|
+
anchorX,
|
|
181
|
+
anchorY,
|
|
182
|
+
x,
|
|
183
|
+
y,
|
|
184
|
+
scale: newScale < 0 ? 0 : newScale
|
|
185
|
+
});
|
|
186
|
+
}, undefined, {
|
|
187
|
+
passive: false
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
getSource(text) {
|
|
191
|
+
if (text) {
|
|
192
|
+
this.loading = true;
|
|
193
|
+
}
|
|
194
|
+
return text;
|
|
195
|
+
}
|
|
196
|
+
updateZoom(zoom = {
|
|
197
|
+
x: 0,
|
|
198
|
+
y: 0,
|
|
199
|
+
anchorX: 0,
|
|
200
|
+
anchorY: 0,
|
|
201
|
+
scale: 0
|
|
202
|
+
}) {
|
|
203
|
+
const {
|
|
204
|
+
anchorX,
|
|
205
|
+
anchorY,
|
|
206
|
+
x,
|
|
207
|
+
y
|
|
208
|
+
} = zoom;
|
|
209
|
+
let {
|
|
210
|
+
scale
|
|
211
|
+
} = zoom;
|
|
212
|
+
this.zoom = zoom;
|
|
213
|
+
const image = this.image;
|
|
214
|
+
if (!image.naturalHeight) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const maxHeight = this.element.clientWidth > this.element.clientHeight;
|
|
218
|
+
const s = maxHeight ? this.element.clientWidth / image.naturalWidth : this.element.clientHeight / image.naturalHeight;
|
|
219
|
+
if (scale <= 0) {
|
|
220
|
+
scale = 0;
|
|
221
|
+
}
|
|
222
|
+
const {
|
|
223
|
+
clientWidth,
|
|
224
|
+
clientHeight
|
|
225
|
+
} = this.element;
|
|
226
|
+
if (scale <= 0) {
|
|
227
|
+
this.element.scrollTo(0, 0);
|
|
228
|
+
this.imageContainer.style.transform = ``;
|
|
229
|
+
return;
|
|
203
230
|
}
|
|
231
|
+
const scaleFactor = (clientWidth + scale) / clientWidth;
|
|
232
|
+
this.imageContainer.style.transformOrigin = `${anchorX}px ${anchorY}px`;
|
|
233
|
+
this.imageContainer.style.transform = `scale(${scaleFactor})`;
|
|
234
|
+
const e = this.imageContainer.getBoundingClientRect();
|
|
235
|
+
const left = -e.left;
|
|
236
|
+
const top = -e.top;
|
|
237
|
+
this.imageContainer.style.transformOrigin = "0 0";
|
|
238
|
+
const de = this.imageContainer.getBoundingClientRect();
|
|
239
|
+
this.scrollDiv.scrollTo({
|
|
240
|
+
left: left + de.left,
|
|
241
|
+
top: top + de.top,
|
|
242
|
+
behavior: "instant"
|
|
243
|
+
});
|
|
244
|
+
}
|
|
204
245
|
}
|
|
205
|
-
__decorate([
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
], ZoomView.prototype, "zoom", void 0);
|
|
209
|
-
__decorate([
|
|
210
|
-
BindableProperty,
|
|
211
|
-
__metadata("design:type", String)
|
|
212
|
-
], ZoomView.prototype, "source", void 0);
|
|
213
|
-
__decorate([
|
|
214
|
-
BindableProperty,
|
|
215
|
-
__metadata("design:type", Boolean)
|
|
216
|
-
], ZoomView.prototype, "loading", void 0);
|
|
217
|
-
//# sourceMappingURL=ZoomView.js.map
|
|
246
|
+
__decorate([BindableProperty, __metadata("design:type", Object)], ZoomView.prototype, "zoom", void 0);
|
|
247
|
+
__decorate([BindableProperty, __metadata("design:type", String)], ZoomView.prototype, "source", void 0);
|
|
248
|
+
__decorate([BindableProperty, __metadata("design:type", Boolean)], ZoomView.prototype, "loading", void 0);
|