@summeruse/ol 0.3.0 → 0.3.1
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/CHANGELOG.md +6 -0
- package/dist/index.js +437 -435
- package/es/composables/usePointermove/index.d.ts +5 -0
- package/es/composables/usePointermove/index.mjs +40 -38
- package/lib/composables/usePointermove/index.d.ts +5 -0
- package/lib/composables/usePointermove/index.js +1 -1
- package/package.json +1 -1
|
@@ -49,12 +49,17 @@ export declare function usePointermove<T extends Option>({ mapRef, items, forceU
|
|
|
49
49
|
x: number;
|
|
50
50
|
y: number;
|
|
51
51
|
}>;
|
|
52
|
+
offset: import('vue').ComputedRef<{
|
|
53
|
+
x: number;
|
|
54
|
+
y: number;
|
|
55
|
+
}>;
|
|
52
56
|
originalPosition: import('vue').ComputedRef<{
|
|
53
57
|
x: number;
|
|
54
58
|
y: number;
|
|
55
59
|
}>;
|
|
56
60
|
feature: import('vue').ComputedRef<FeatureLike | undefined>;
|
|
57
61
|
content: import('vue').ComputedRef<string | (() => VNodeChild) | undefined>;
|
|
62
|
+
originalCoordinate: import('vue').ComputedRef<Coordinate | undefined>;
|
|
58
63
|
coordinate: import('vue').ComputedRef<Coordinate | undefined>;
|
|
59
64
|
option: import('vue').ComputedRef<T | undefined>;
|
|
60
65
|
hide: () => void;
|
|
@@ -7,30 +7,30 @@ function usePointermove({ mapRef: o, items: s, forceUpdate: c = !1 }) {
|
|
|
7
7
|
}), d = ref(), f = ref(), p = ref({
|
|
8
8
|
x: 0,
|
|
9
9
|
y: 0
|
|
10
|
-
}), m = ref(), h = ref(), g = computed(() => ({
|
|
10
|
+
}), m = ref(), h = ref(), g = ref(), _ = computed(() => ({
|
|
11
11
|
x: u.value.x + p.value.x,
|
|
12
12
|
y: u.value.y + p.value.y
|
|
13
|
-
})),
|
|
14
|
-
function
|
|
13
|
+
})), v, y, b = "";
|
|
14
|
+
function x(e) {
|
|
15
15
|
let t = toValue(s);
|
|
16
16
|
return t.sort((e, t) => (t.priority ?? 0) - (e.priority ?? 0)), t.find((t) => {
|
|
17
17
|
let n = t.visible;
|
|
18
18
|
return typeof n == "function" ? n(e) : n ?? !0;
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
if (e.dragging || !
|
|
21
|
+
function S(e) {
|
|
22
|
+
if (e.dragging || !v || !y) return;
|
|
23
23
|
let t = e.coordinate;
|
|
24
|
-
m.value = t;
|
|
24
|
+
m.value = t, h.value = t;
|
|
25
25
|
let n = e.pixel, r, i;
|
|
26
|
-
if (
|
|
27
|
-
|
|
26
|
+
if (v.forEachFeatureAtPixel(n, (e, t) => (r = e, i = t, !0)), !r) {
|
|
27
|
+
C();
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
if (!c && d.value && d.value.getId() === r.getId()) return;
|
|
31
31
|
d.value = r;
|
|
32
|
-
let { top: o, left: s } =
|
|
33
|
-
map:
|
|
32
|
+
let { top: o, left: s } = y.getBoundingClientRect(), _ = {
|
|
33
|
+
map: v,
|
|
34
34
|
position: {
|
|
35
35
|
x: n[0] + s,
|
|
36
36
|
y: n[1] + o
|
|
@@ -38,52 +38,54 @@ function usePointermove({ mapRef: o, items: s, forceUpdate: c = !1 }) {
|
|
|
38
38
|
coordinate: t,
|
|
39
39
|
feature: r,
|
|
40
40
|
layer: i
|
|
41
|
-
},
|
|
42
|
-
if (
|
|
43
|
-
let { content: e, cursor: t, visible: n, fixedFeatureCenter: r, offset: i, priority: a,...o } =
|
|
44
|
-
|
|
41
|
+
}, b = x(_);
|
|
42
|
+
if (b) {
|
|
43
|
+
let { content: e, cursor: t, visible: n, fixedFeatureCenter: r, offset: i, priority: a,...o } = b;
|
|
44
|
+
g.value = { ...o };
|
|
45
45
|
}
|
|
46
|
-
if (!
|
|
47
|
-
|
|
46
|
+
if (!b) {
|
|
47
|
+
C();
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
p.value = {
|
|
51
|
-
x:
|
|
52
|
-
y:
|
|
51
|
+
x: b.offset?.x ?? 0,
|
|
52
|
+
y: b.offset?.y ?? 0
|
|
53
53
|
};
|
|
54
|
-
let
|
|
55
|
-
if (
|
|
56
|
-
let e = getCenter(
|
|
57
|
-
n =
|
|
54
|
+
let S = c === !1 ? !0 : b.fixedFeatureCenter ?? !0, w = r.getGeometry();
|
|
55
|
+
if (S && w) {
|
|
56
|
+
let e = getCenter(w.getExtent());
|
|
57
|
+
h.value = e, n = v.getPixelFromCoordinate(e);
|
|
58
58
|
}
|
|
59
59
|
u.value.x = n[0] + s, u.value.y = n[1] + o;
|
|
60
|
-
let
|
|
61
|
-
f.value = typeof
|
|
62
|
-
let
|
|
63
|
-
|
|
60
|
+
let T = b.content;
|
|
61
|
+
f.value = typeof T == "function" ? () => T(_) : T;
|
|
62
|
+
let E = b.cursor, D = typeof E == "function" ? E(_) : E;
|
|
63
|
+
D !== void 0 && D !== y.style.cursor && (y.style.cursor = D), l.value = !0;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
l.value = !1, d.value = void 0,
|
|
67
|
-
}
|
|
68
|
-
function C(e) {
|
|
69
|
-
e.on("pointermove", x);
|
|
65
|
+
function C() {
|
|
66
|
+
l.value = !1, d.value = void 0, y && y.style.cursor !== b && (y.style.cursor = b);
|
|
70
67
|
}
|
|
71
68
|
function w(e) {
|
|
72
|
-
e.
|
|
69
|
+
e.on("pointermove", S);
|
|
70
|
+
}
|
|
71
|
+
function T(e) {
|
|
72
|
+
e.un("pointermove", S);
|
|
73
73
|
}
|
|
74
74
|
return watch(() => toValue(o), (e, t) => {
|
|
75
|
-
t &&
|
|
75
|
+
t && T(t), t !== e && (v = e, e && (y = e.getViewport(), w(e), b = y.style.cursor));
|
|
76
76
|
}, { immediate: !0 }), onBeforeUnmount(() => {
|
|
77
|
-
|
|
77
|
+
v && T(v);
|
|
78
78
|
}), {
|
|
79
79
|
visible: computed(() => l.value),
|
|
80
|
-
position: computed(() =>
|
|
80
|
+
position: computed(() => _.value),
|
|
81
|
+
offset: computed(() => p.value),
|
|
81
82
|
originalPosition: computed(() => u.value),
|
|
82
83
|
feature: computed(() => d.value),
|
|
83
84
|
content: computed(() => f.value),
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
originalCoordinate: computed(() => m.value),
|
|
86
|
+
coordinate: computed(() => h.value),
|
|
87
|
+
option: computed(() => g.value),
|
|
88
|
+
hide: C
|
|
87
89
|
};
|
|
88
90
|
}
|
|
89
91
|
export { usePointermove };
|
|
@@ -49,12 +49,17 @@ export declare function usePointermove<T extends Option>({ mapRef, items, forceU
|
|
|
49
49
|
x: number;
|
|
50
50
|
y: number;
|
|
51
51
|
}>;
|
|
52
|
+
offset: import('vue').ComputedRef<{
|
|
53
|
+
x: number;
|
|
54
|
+
y: number;
|
|
55
|
+
}>;
|
|
52
56
|
originalPosition: import('vue').ComputedRef<{
|
|
53
57
|
x: number;
|
|
54
58
|
y: number;
|
|
55
59
|
}>;
|
|
56
60
|
feature: import('vue').ComputedRef<FeatureLike | undefined>;
|
|
57
61
|
content: import('vue').ComputedRef<string | (() => VNodeChild) | undefined>;
|
|
62
|
+
originalCoordinate: import('vue').ComputedRef<Coordinate | undefined>;
|
|
58
63
|
coordinate: import('vue').ComputedRef<Coordinate | undefined>;
|
|
59
64
|
option: import('vue').ComputedRef<T | undefined>;
|
|
60
65
|
hide: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../_virtual/rolldown_runtime.js`);let t=require(`vue`);t=e.__toESM(t);let n=require(`ol/extent`);n=e.__toESM(n);function r({mapRef:e,items:r,forceUpdate:i=!1}){let a=(0,t.ref)(!1),o=(0,t.ref)({x:0,y:0}),s=(0,t.ref)(),c=(0,t.ref)(),l=(0,t.ref)({x:0,y:0}),u=(0,t.ref)(),d=(0,t.ref)(),f=(0,t.computed)(()=>({x:o.value.x+l.value.x,y:o.value.y+l.value.y})),
|
|
1
|
+
const e=require(`../../_virtual/rolldown_runtime.js`);let t=require(`vue`);t=e.__toESM(t);let n=require(`ol/extent`);n=e.__toESM(n);function r({mapRef:e,items:r,forceUpdate:i=!1}){let a=(0,t.ref)(!1),o=(0,t.ref)({x:0,y:0}),s=(0,t.ref)(),c=(0,t.ref)(),l=(0,t.ref)({x:0,y:0}),u=(0,t.ref)(),d=(0,t.ref)(),f=(0,t.ref)(),p=(0,t.computed)(()=>({x:o.value.x+l.value.x,y:o.value.y+l.value.y})),m,h,g=``;function _(e){let n=(0,t.toValue)(r);return n.sort((e,t)=>(t.priority??0)-(e.priority??0)),n.find(t=>{let n=t.visible;return typeof n==`function`?n(e):n??!0})}function v(e){if(e.dragging||!m||!h)return;let t=e.coordinate;u.value=t,d.value=t;let r=e.pixel,p,g;if(m.forEachFeatureAtPixel(r,(e,t)=>(p=e,g=t,!0)),!p){y();return}if(!i&&s.value&&s.value.getId()===p.getId())return;s.value=p;let{top:v,left:b}=h.getBoundingClientRect(),x={map:m,position:{x:r[0]+b,y:r[1]+v},coordinate:t,feature:p,layer:g},S=_(x);if(S){let{content:e,cursor:t,visible:n,fixedFeatureCenter:r,offset:i,priority:a,...o}=S;f.value={...o}}if(!S){y();return}l.value={x:S.offset?.x??0,y:S.offset?.y??0};let C=i===!1?!0:S.fixedFeatureCenter??!0,w=p.getGeometry();if(C&&w){let e=(0,n.getCenter)(w.getExtent());d.value=e,r=m.getPixelFromCoordinate(e)}o.value.x=r[0]+b,o.value.y=r[1]+v;let T=S.content;c.value=typeof T==`function`?()=>T(x):T;let E=S.cursor,D=typeof E==`function`?E(x):E;D!==void 0&&D!==h.style.cursor&&(h.style.cursor=D),a.value=!0}function y(){a.value=!1,s.value=void 0,h&&h.style.cursor!==g&&(h.style.cursor=g)}function b(e){e.on(`pointermove`,v)}function x(e){e.un(`pointermove`,v)}return(0,t.watch)(()=>(0,t.toValue)(e),(e,t)=>{t&&x(t),t!==e&&(m=e,e&&(h=e.getViewport(),b(e),g=h.style.cursor))},{immediate:!0}),(0,t.onBeforeUnmount)(()=>{m&&x(m)}),{visible:(0,t.computed)(()=>a.value),position:(0,t.computed)(()=>p.value),offset:(0,t.computed)(()=>l.value),originalPosition:(0,t.computed)(()=>o.value),feature:(0,t.computed)(()=>s.value),content:(0,t.computed)(()=>c.value),originalCoordinate:(0,t.computed)(()=>u.value),coordinate:(0,t.computed)(()=>d.value),option:(0,t.computed)(()=>f.value),hide:y}}exports.usePointermove=r;
|