Skip to content

Commit 1a7712c

Browse files
authored
control position support Any CSS value (#2202)
1 parent ef4bd85 commit 1a7712c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/control/Control.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { extend, isNil, isString } from '../core/util';
1+
import { extend, isNil, isNumber, isString } from '../core/util';
22
import { createEl, setStyle, removeDomNode } from '../core/util/dom';
33
import Eventable from '../core/Eventable';
44
import Class from '../core/Class';
@@ -229,8 +229,11 @@ class Control extends Eventable(Class) {
229229
}
230230
for (const p in position) {
231231
if (position.hasOwnProperty(p)) {
232-
position[p] = parseInt(position[p]);
233-
this.__ctrlContainer.style[p] = position[p] + 'px';
232+
let v = position[p] || 0;
233+
if (isNumber(v)) {
234+
v += 'px';
235+
}
236+
this.__ctrlContainer.style[p] = v;
234237
}
235238
}
236239
/**
@@ -251,20 +254,20 @@ class Control extends Eventable(Class) {
251254

252255
Control.positions = {
253256
'top-left': {
254-
'top' : 20,
255-
'left' : 20
257+
'top': 20,
258+
'left': 20
256259
},
257260
'top-right': {
258-
'top' : 20,
259-
'right' : 20
261+
'top': 20,
262+
'right': 20
260263
},
261264
'bottom-left': {
262265
'bottom': 20,
263-
'left' : 20
266+
'left': 20
264267
},
265268
'bottom-right': {
266269
'bottom': 20,
267-
'right' : 20
270+
'right': 20
268271
}
269272
};
270273

0 commit comments

Comments
 (0)