rexma-design 1.4.3 → 1.5.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.
|
@@ -43,9 +43,13 @@ type IImageMapProps = {
|
|
|
43
43
|
image: string;
|
|
44
44
|
/** 点的集合 */
|
|
45
45
|
marks: IMark[];
|
|
46
|
+
/** 默认居中展示地图 */
|
|
47
|
+
defaultCenter?: boolean;
|
|
46
48
|
};
|
|
47
49
|
|
|
48
|
-
const props = defineProps<IImageMapProps>()
|
|
50
|
+
const props = withDefaults(defineProps<IImageMapProps>(), {
|
|
51
|
+
defaultCenter: false,
|
|
52
|
+
});
|
|
49
53
|
const emit = defineEmits(['markClick']);
|
|
50
54
|
|
|
51
55
|
const maxScale = 3;
|
|
@@ -133,13 +137,10 @@ function getElRect(elType: 'map' | 'mapWrap'): Record<'width' | 'height' | 'x' |
|
|
|
133
137
|
};
|
|
134
138
|
}
|
|
135
139
|
|
|
136
|
-
window.getElRect = getElRect;
|
|
137
|
-
|
|
138
140
|
/**
|
|
139
141
|
* @description 拖动开始事件
|
|
140
142
|
*/
|
|
141
143
|
function touchstart(e: TouchEvent) {
|
|
142
|
-
console.log('on touch');
|
|
143
144
|
if (e.touches.length === 1) {
|
|
144
145
|
// 单指移动
|
|
145
146
|
slideStart.value = {
|
|
@@ -172,7 +173,6 @@ function touchstart(e: TouchEvent) {
|
|
|
172
173
|
}
|
|
173
174
|
scaleCenter.value = _scaleCenter;
|
|
174
175
|
scaleDistance.value = Math.hypot(touchA.pageX - touchB.pageX, touchA.pageY - touchB.pageY);
|
|
175
|
-
console.log(scaleCenter.value, scaleDistance.value);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
|
|
@@ -289,7 +289,9 @@ function onImageLoad(e: any) {
|
|
|
289
289
|
xRange: [-(mapRect.width - mapWrapRect.width), 0],
|
|
290
290
|
yRange: [-(mapRect.height - mapWrapRect.height), 0],
|
|
291
291
|
};
|
|
292
|
-
|
|
292
|
+
if (props.defaultCenter) {
|
|
293
|
+
translate.value.x = -(mapRect.width - mapWrapRect.width) / 2;
|
|
294
|
+
}
|
|
293
295
|
}
|
|
294
296
|
|
|
295
297
|
watch([scale, translate], function () {
|