@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.
@@ -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
- })), _, v, y = "";
14
- function b(e) {
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 x(e) {
22
- if (e.dragging || !_ || !v) return;
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 (_.forEachFeatureAtPixel(n, (e, t) => (r = e, i = t, !0)), !r) {
27
- S();
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 } = v.getBoundingClientRect(), g = {
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
- }, y = b(g);
42
- if (y) {
43
- let { content: e, cursor: t, visible: n, fixedFeatureCenter: r, offset: i, priority: a,...o } = y;
44
- h.value = { ...o };
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 (!y) {
47
- S();
46
+ if (!b) {
47
+ C();
48
48
  return;
49
49
  }
50
50
  p.value = {
51
- x: y.offset?.x ?? 0,
52
- y: y.offset?.y ?? 0
51
+ x: b.offset?.x ?? 0,
52
+ y: b.offset?.y ?? 0
53
53
  };
54
- let x = c === !1 ? !0 : y.fixedFeatureCenter ?? !0, C = r.getGeometry();
55
- if (x && C) {
56
- let e = getCenter(C.getExtent());
57
- n = _.getPixelFromCoordinate(e);
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 w = y.content;
61
- f.value = typeof w == "function" ? () => w(g) : w;
62
- let T = y.cursor, E = typeof T == "function" ? T(g) : T;
63
- E !== void 0 && E !== v.style.cursor && (v.style.cursor = E), l.value = !0;
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 S() {
66
- l.value = !1, d.value = void 0, v && v.style.cursor !== y && (v.style.cursor = y);
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.un("pointermove", x);
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 && w(t), t !== e && (_ = e, e && (v = e.getViewport(), C(e), y = v.style.cursor));
75
+ t && T(t), t !== e && (v = e, e && (y = e.getViewport(), w(e), b = y.style.cursor));
76
76
  }, { immediate: !0 }), onBeforeUnmount(() => {
77
- _ && w(_);
77
+ v && T(v);
78
78
  }), {
79
79
  visible: computed(() => l.value),
80
- position: computed(() => g.value),
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
- coordinate: computed(() => m.value),
85
- option: computed(() => h.value),
86
- hide: S
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})),p,m,h=``;function g(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 _(e){if(e.dragging||!p||!m)return;let t=e.coordinate;u.value=t;let r=e.pixel,f,h;if(p.forEachFeatureAtPixel(r,(e,t)=>(f=e,h=t,!0)),!f){v();return}if(!i&&s.value&&s.value.getId()===f.getId())return;s.value=f;let{top:_,left:y}=m.getBoundingClientRect(),b={map:p,position:{x:r[0]+y,y:r[1]+_},coordinate:t,feature:f,layer:h},x=g(b);if(x){let{content:e,cursor:t,visible:n,fixedFeatureCenter:r,offset:i,priority:a,...o}=x;d.value={...o}}if(!x){v();return}l.value={x:x.offset?.x??0,y:x.offset?.y??0};let S=i===!1?!0:x.fixedFeatureCenter??!0,C=f.getGeometry();if(S&&C){let e=(0,n.getCenter)(C.getExtent());r=p.getPixelFromCoordinate(e)}o.value.x=r[0]+y,o.value.y=r[1]+_;let w=x.content;c.value=typeof w==`function`?()=>w(b):w;let T=x.cursor,E=typeof T==`function`?T(b):T;E!==void 0&&E!==m.style.cursor&&(m.style.cursor=E),a.value=!0}function v(){a.value=!1,s.value=void 0,m&&m.style.cursor!==h&&(m.style.cursor=h)}function y(e){e.on(`pointermove`,_)}function b(e){e.un(`pointermove`,_)}return(0,t.watch)(()=>(0,t.toValue)(e),(e,t)=>{t&&b(t),t!==e&&(p=e,e&&(m=e.getViewport(),y(e),h=m.style.cursor))},{immediate:!0}),(0,t.onBeforeUnmount)(()=>{p&&b(p)}),{visible:(0,t.computed)(()=>a.value),position:(0,t.computed)(()=>f.value),originalPosition:(0,t.computed)(()=>o.value),feature:(0,t.computed)(()=>s.value),content:(0,t.computed)(()=>c.value),coordinate:(0,t.computed)(()=>u.value),option:(0,t.computed)(()=>d.value),hide:v}}exports.usePointermove=r;
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@summeruse/ol",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "description": "",
6
6
  "author": "finalsummer",
7
7
  "license": "ISC",