Skip to content

Commit 10d0693

Browse files
authored
auto Control update position when options.position update (#2477)
1 parent a1c452a commit 10d0693

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/control/Control.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { extend, isNil, isNumber, isString } from '../core/util';
22
import { createEl, setStyle, removeDomNode } from '../core/util/dom';
33
import Eventable from '../core/Eventable';
4-
import Class from '../core/Class';
4+
import Class, { ClassOptions } from '../core/Class';
55
import Point from '../geo/Point';
66
import Map from '../map/Map';
77

@@ -267,6 +267,10 @@ abstract class Control<T = ControlOptionsType> extends Eventable(Class) {
267267
'left': 20
268268
};
269269
}
270+
//reset position style value
271+
if (this.__ctrlContainer) {
272+
Object.assign(this.__ctrlContainer.style, { top: null, bottom: null, right: null, left: null });
273+
}
270274
for (const p in position) {
271275
if (position.hasOwnProperty(p)) {
272276
let v = position[p] || 0;
@@ -290,6 +294,12 @@ abstract class Control<T = ControlOptionsType> extends Eventable(Class) {
290294
});
291295
}
292296

297+
onConfig(conf: ClassOptions): void {
298+
if (conf && 'position' in conf) {
299+
this._updatePosition();
300+
}
301+
}
302+
293303
}
294304

295305
Control.positions = {

0 commit comments

Comments
 (0)