@community-release/nx-ui 0.0.34 → 0.0.35

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/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "ui",
3
3
  "configKey": "ui",
4
- "version": "0.0.34"
4
+ "version": "0.0.35"
5
5
  }
@@ -77,15 +77,15 @@ const props = defineProps({
77
77
  },
78
78
  });
79
79
 
80
- store.setCoord(props.coord);
81
- store.setZoom(props.zoom);
82
- store.setZoomMin(props.zoomMin);
83
- store.setZoomMax(props.zoomMax);
84
- store.setDeviceZoom(props.deviceZoom);
85
- store.setMarkers(props.markers);
86
- store.setMarkerImage(props.markerImage);
87
- store.setMarkerActiveImage(props.markerActiveImage);
88
- store.setMarkerDisabledImage(props.markerDisabledImage);
80
+ store.coord = props.coord;
81
+ store.zoom = props.zoom;
82
+ store.zoomMin = props.zoomMin;
83
+ store.zoomMax = props.zoomMax;
84
+ store.deviceZoom = props.deviceZoom;
85
+ store.markers = props.markers;
86
+ store.markerImage = props.markerImage;
87
+ store.markerActiveImage = props.markerActiveImage;
88
+ store.markerDisabledImage = props.markerDisabledImage;
89
89
 
90
90
  watch(() => props.disabledMarkers, (v) => {
91
91
  store.setDisabledMarkers(v);
@@ -71,7 +71,7 @@
71
71
  async function handleClick() {
72
72
  if (clickInProcess) return;
73
73
  clickInProcess = true;
74
-
74
+
75
75
  try {
76
76
  // If cache not exist or it's older than 1 minute
77
77
  if (!cachedPosition || Date.now() - cachedTime > 60000) {
@@ -92,13 +92,15 @@
92
92
  );
93
93
 
94
94
  // Set coord and zoom
95
+ // Pan to user location
95
96
  store.setCoord(cachedPosition, 750);
96
- store.setZoom(14);
97
+ store.setZoom(14, 750);
97
98
 
98
99
  await wait(2000);
99
100
 
101
+ // Pan to nearest marker location
100
102
  store.setCoord(nearest.coord, 1500);
101
- store.setZoom(nearest?.zoom ? nearest.zoom : 14);
103
+ store.setZoom(nearest?.zoom ? nearest.zoom : 14, 1500);
102
104
  } catch (err) {
103
105
  console.log('handleClick err', err);
104
106
 
@@ -61,8 +61,10 @@
61
61
  // Store
62
62
  const store = useMapStore();
63
63
  const {
64
+ cameraDuration,
64
65
  requestCoordChange,
65
66
  coord,
67
+ requestZoomChange,
66
68
  zoom,
67
69
  zoomMin,
68
70
  zoomMax,
@@ -84,24 +86,23 @@
84
86
  redrawMarkers();
85
87
  });
86
88
 
87
- // Watch coord
88
- watch([requestCoordChange, coord], (v) => {
89
- const req = v[0];
89
+ // Watch coord or zoom change
90
+ watch([requestCoordChange, requestZoomChange], () => {
91
+ if (!requestCoordChange.value && !requestZoomChange.value) return;
90
92
 
91
- if (!req) return;
93
+ console.log('Watch coord or zoom change');
92
94
 
93
- const coord = fromLonLat(v[1]);
95
+ const options = {
96
+ duration: cameraDuration.value
97
+ };
94
98
 
95
- // If req === 1 then set coord instantly
96
- if (req === 1) {
97
- view.setCenter(coord);
98
- // If req === 2 then set coord in default duration, else treat req as duration time in ms
99
- } else {
100
- const duration = req === 2 ? 300 : req;
101
- view.animate({center: coord, duration});
102
- }
99
+ if (requestCoordChange.value) options.center = fromLonLat(coord.value);
100
+ if (requestZoomChange.value) options.zoom = zoom.value;
103
101
 
104
- requestCoordChange.value = 0;
102
+ view.animate(options, () => {
103
+ requestCoordChange.value = false;
104
+ requestZoomChange.value = false;
105
+ });
105
106
  });
106
107
 
107
108
  // Watch user coord
@@ -109,20 +110,20 @@
109
110
  userPositionMarker.setPosition(fromLonLat(v));
110
111
  });
111
112
 
112
- // Watch zoom
113
- watch(zoom, (v) => {
114
- const currentZoom = view.getZoom();
113
+ // // Watch zoom
114
+ // watch(zoom, (v) => {
115
+ // const currentZoom = view.getZoom();
115
116
 
116
- if (currentZoom === v) return;
117
+ // if (currentZoom === v) return;
117
118
 
118
- if (initialized)
119
- view.animate({
120
- zoom: v,
121
- duration: 300
122
- });
123
- else
124
- view.setZoom(v);
125
- });
119
+ // if (initialized)
120
+ // view.animate({
121
+ // zoom: v,
122
+ // duration: 300
123
+ // });
124
+ // else
125
+ // view.setZoom(v);
126
+ // });
126
127
 
127
128
  const payload = {
128
129
  store,
@@ -373,7 +374,7 @@
373
374
 
374
375
  map.on('loadend', () => {
375
376
  if (initialized) return;
376
-
377
+
377
378
  initialized = true;
378
379
  emit('initialized', payload);
379
380
  });
@@ -1,6 +1,8 @@
1
1
  export const useMapStore: import("pinia").StoreDefinition<"map", {
2
- requestCoordChange: number;
2
+ cameraDuration: number;
3
+ requestCoordChange: boolean;
3
4
  coord: never[];
5
+ requestZoomChange: boolean;
4
6
  zoom: number;
5
7
  zoomMin: number;
6
8
  zoomMax: number;
@@ -22,9 +24,10 @@ export const useMapStore: import("pinia").StoreDefinition<"map", {
22
24
  }, {
23
25
  /**
24
26
  * Set map zoom
25
- * @param {number} v
27
+ * @param {number} zoom
28
+ * @param {number} duration
26
29
  */
27
- setZoom(v: number): void;
30
+ setZoom(zoom: number, duration?: number): void;
28
31
  /**
29
32
  * Set min map zoom
30
33
  * @param {number} v
@@ -41,10 +44,10 @@ export const useMapStore: import("pinia").StoreDefinition<"map", {
41
44
  zoomOut(): void;
42
45
  /**
43
46
  * Set map coord
44
- * @param {MapCoord} v
45
- * @param {number} requestCoordChange - 1 default, 2 animated
47
+ * @param {number} coord
48
+ * @param {number} duration
46
49
  */
47
- setCoord(v: MapCoord, requestCoordChange?: number): void;
50
+ setCoord(coord: number, duration?: number): void;
48
51
  /**
49
52
  * Set user coord
50
53
  * @param {MapCoord} v
@@ -18,9 +18,10 @@ import { defineStore } from 'pinia';
18
18
  export const useMapStore = defineStore('map', {
19
19
  state: () => {
20
20
  return {
21
- requestCoordChange: 0,
21
+ cameraDuration: 0,
22
+ requestCoordChange: false,
22
23
  coord: [],
23
-
24
+ requestZoomChange: false,
24
25
  zoom: 8,
25
26
  zoomMin: 8,
26
27
  zoomMax: 18,
@@ -41,10 +42,13 @@ export const useMapStore = defineStore('map', {
41
42
  actions: {
42
43
  /**
43
44
  * Set map zoom
44
- * @param {number} v
45
+ * @param {number} zoom
46
+ * @param {number} duration
45
47
  */
46
- setZoom(v) {
47
- this.zoom = v;
48
+ setZoom(zoom, duration = 300) {
49
+ this.zoom = zoom;
50
+ this.cameraDuration = duration;
51
+ this.requestZoomChange = true;
48
52
  },
49
53
 
50
54
  /**
@@ -72,6 +76,8 @@ export const useMapStore = defineStore('map', {
72
76
  }
73
77
 
74
78
  this.zoom++;
79
+ this.cameraDuration = 300;
80
+ this.requestZoomChange = true;
75
81
  },
76
82
 
77
83
  /** Map zoom out */
@@ -83,16 +89,19 @@ export const useMapStore = defineStore('map', {
83
89
  }
84
90
 
85
91
  this.zoom--;
92
+ this.cameraDuration = 300;
93
+ this.requestZoomChange = true;
86
94
  },
87
95
 
88
96
  /**
89
97
  * Set map coord
90
- * @param {MapCoord} v
91
- * @param {number} requestCoordChange - 1 default, 2 animated
98
+ * @param {number} coord
99
+ * @param {number} duration
92
100
  */
93
- setCoord(v, requestCoordChange = 1) {
94
- this.requestCoordChange = requestCoordChange;
95
- this.coord = v;
101
+ setCoord(coord, duration = 300) {
102
+ this.coord = coord;
103
+ this.cameraDuration = duration;
104
+ this.requestCoordChange = true;
96
105
  },
97
106
 
98
107
  /**
@@ -1,9 +1,9 @@
1
1
  <template>
2
2
  <div class="component-ui-map-zoom">
3
3
  <div class="prepend"><slot /></div>
4
- <ui-button @click="store.zoomIn" color="gray" block variant="flat" size="small" shape="square">+</ui-button>
4
+ <ui-button @click="store.zoomIn" class="plus" color="gray" block variant="flat" size="small" shape="square">+</ui-button>
5
5
  <div class="separator"></div>
6
- <ui-button @click="store.zoomOut" color="gray" block variant="flat" size="small" shape="square">-</ui-button>
6
+ <ui-button @click="store.zoomOut" class="minus" color="gray" block variant="flat" size="small" shape="square">-</ui-button>
7
7
  </div>
8
8
  </template>
9
9
 
@@ -54,6 +54,16 @@ const props = defineProps(['store']);
54
54
  font-size: @com-text-large;
55
55
  }
56
56
 
57
+ .component-ui-button.plus .button-bg {
58
+ border-top-left-radius: @com-border-radius-default;
59
+ border-top-right-radius: @com-border-radius-default;
60
+ }
61
+
62
+ .component-ui-button.minus .button-bg {
63
+ border-bottom-left-radius: @com-border-radius-default;
64
+ border-bottom-right-radius: @com-border-radius-default;
65
+ }
66
+
57
67
  .separator {
58
68
  border-bottom: 1px solid @com-color-border;
59
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@community-release/nx-ui",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "nx-ui - Nuxt UI library",
5
5
  "repository": {
6
6
  "type": "git",