Skip to content

Control auto update position when options.position update #2477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/control/Control.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { extend, isNil, isNumber, isString } from '../core/util';
import { createEl, setStyle, removeDomNode } from '../core/util/dom';
import Eventable from '../core/Eventable';
import Class from '../core/Class';
import Class, { ClassOptions } from '../core/Class';
import Point from '../geo/Point';
import Map from '../map/Map';

Expand Down Expand Up @@ -267,6 +267,10 @@ abstract class Control<T = ControlOptionsType> extends Eventable(Class) {
'left': 20
};
}
//reset position style value
if (this.__ctrlContainer) {
Object.assign(this.__ctrlContainer.style, { top: null, bottom: null, right: null, left: null });
}
for (const p in position) {
if (position.hasOwnProperty(p)) {
let v = position[p] || 0;
Expand All @@ -290,6 +294,12 @@ abstract class Control<T = ControlOptionsType> extends Eventable(Class) {
});
}

onConfig(conf: ClassOptions): void {
if (conf && 'position' in conf) {
this._updatePosition();
}
}

}

Control.positions = {
Expand Down