Skip to content

Commit 7070703

Browse files
committed
Revert "feat(CustomMarker): add fastdom to batch reads and writes to the DOM"
This reverts commit cd405e9.
1 parent 1d50fd3 commit 7070703

File tree

2 files changed

+52
-59
lines changed

2 files changed

+52
-59
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@
5353
"dependencies": {
5454
"@googlemaps/js-api-loader": "^1.16.2",
5555
"@googlemaps/markerclusterer": "^2.4.0",
56-
"fast-deep-equal": "^3.1.3",
57-
"fastdom": "^1.0.11"
56+
"fast-deep-equal": "^3.1.3"
5857
},
5958
"devDependencies": {
6059
"pnpm": "^8.7.6",

src/utils/index.ts

Lines changed: 51 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import fastdom from "fastdom";
21
type ICustomMarkerInterface = google.maps.OverlayView & {
32
getPosition(): google.maps.LatLng | null;
43
getVisible(): boolean;
@@ -63,62 +62,57 @@ export function createCustomMarkerClass(api: typeof google.maps): ICustomMarkerC
6362
const point = overlayProjection?.fromLatLngToDivPixel(this.getPosition());
6463

6564
if (point) {
66-
const element = this.element;
67-
fastdom.measure(() => {
68-
const height = element.offsetHeight;
69-
const width = element.offsetWidth;
70-
let x: number, y: number;
71-
switch (this.opts.anchorPoint) {
72-
case "TOP_CENTER":
73-
x = point.x - width / 2;
74-
y = point.y;
75-
break;
76-
case "BOTTOM_CENTER":
77-
x = point.x - width / 2;
78-
y = point.y - height;
79-
break;
80-
case "LEFT_CENTER":
81-
x = point.x;
82-
y = point.y - height / 2;
83-
break;
84-
case "RIGHT_CENTER":
85-
x = point.x - width;
86-
y = point.y - height / 2;
87-
break;
88-
case "TOP_LEFT":
89-
x = point.x;
90-
y = point.y;
91-
break;
92-
case "TOP_RIGHT":
93-
x = point.x - width;
94-
y = point.y;
95-
break;
96-
case "BOTTOM_LEFT":
97-
x = point.x;
98-
y = point.y - height;
99-
break;
100-
case "BOTTOM_RIGHT":
101-
x = point.x - width;
102-
y = point.y - height;
103-
break;
104-
default:
105-
// "center"
106-
x = point.x - width / 2;
107-
y = point.y - height / 2;
108-
}
109-
110-
fastdom.mutate(() => {
111-
element.style.position = "absolute";
112-
element.style.left = x + "px";
113-
element.style.top = y + "px";
114-
// eslint-disable-next-line prettier/prettier
115-
element.style.transform = `translateX(${this.opts.offsetX || 0}px) translateY(${this.opts.offsetY || 0}px)`;
116-
117-
if (this.opts.zIndex) {
118-
element.style.zIndex = this.opts.zIndex.toString();
119-
}
120-
});
121-
});
65+
this.element.style.position = "absolute";
66+
const height = this.element.offsetHeight;
67+
const width = this.element.offsetWidth;
68+
let x: number, y: number;
69+
switch (this.opts.anchorPoint) {
70+
case "TOP_CENTER":
71+
x = point.x - width / 2;
72+
y = point.y;
73+
break;
74+
case "BOTTOM_CENTER":
75+
x = point.x - width / 2;
76+
y = point.y - height;
77+
break;
78+
case "LEFT_CENTER":
79+
x = point.x;
80+
y = point.y - height / 2;
81+
break;
82+
case "RIGHT_CENTER":
83+
x = point.x - width;
84+
y = point.y - height / 2;
85+
break;
86+
case "TOP_LEFT":
87+
x = point.x;
88+
y = point.y;
89+
break;
90+
case "TOP_RIGHT":
91+
x = point.x - width;
92+
y = point.y;
93+
break;
94+
case "BOTTOM_LEFT":
95+
x = point.x;
96+
y = point.y - height;
97+
break;
98+
case "BOTTOM_RIGHT":
99+
x = point.x - width;
100+
y = point.y - height;
101+
break;
102+
default:
103+
// "center"
104+
x = point.x - width / 2;
105+
y = point.y - height / 2;
106+
}
107+
108+
this.element.style.left = x + "px";
109+
this.element.style.top = y + "px";
110+
// eslint-disable-next-line prettier/prettier
111+
this.element.style.transform = `translateX(${this.opts.offsetX || 0}px) translateY(${this.opts.offsetY || 0}px)`;
112+
113+
if (this.opts.zIndex) {
114+
this.element.style.zIndex = this.opts.zIndex.toString();
115+
}
122116
}
123117
}
124118

0 commit comments

Comments
 (0)