Skip to content

Commit d80f965

Browse files
committed
rename option to anchorPreference
1 parent 496385c commit d80f965

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/ui/popup.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const defaultOptions = {
2020
focusAfterOpen: true,
2121
className: '',
2222
maxWidth: "240px",
23-
stickyAnchor: 'bottom'
23+
anchorPreference: 'bottom'
2424
};
2525

2626
export type Offset = number | PointLike | {[_: Anchor]: PointLike};
@@ -34,7 +34,7 @@ export type PopupOptions = {
3434
offset?: Offset,
3535
className?: string,
3636
maxWidth?: string,
37-
stickyAnchor: Anchor
37+
anchorPreference: Anchor
3838
};
3939

4040
const focusQuerySelector = [
@@ -59,7 +59,7 @@ const focusQuerySelector = [
5959
* map moves.
6060
* @param {boolean} [options.focusAfterOpen=true] If `true`, the popup will try to focus the
6161
* first focusable element inside the popup.
62-
* @param {string} [options.stickyAnchor='bottom'] - A string to set the preference for where the anchor will be
62+
* @param {string} [options.anchorPreference='bottom'] - A string to set the preference for where the anchor will be
6363
* dynamically set. Options are `'center'`, `'top'`, `'bottom'`, `'left'`, `'right'`, `'top-left'`, `'top-right'`,
6464
* `'bottom-left'`, and `'bottom-right'`.
6565
* @param {string} [options.anchor] - A string indicating the part of the popup that should
@@ -580,7 +580,7 @@ export default class Popup extends Evented {
580580
}
581581

582582
if (anchorComponents.length === 0) {
583-
return this.options.stickyAnchor;
583+
return this.options.anchorPreference;
584584
}
585585
return ((anchorComponents.join('-'): any): Anchor);
586586

test/unit/ui/popup.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,13 +480,13 @@ test('Popup automatically anchors to top if its bottom offset would push it off-
480480
t.end();
481481
});
482482

483-
test('Popup automatically anchors to its sticky position if no offset would push it off-screen', (t) => {
483+
test('Popup automatically anchors to the user specified preferred position if will be on-screen', (t) => {
484484
const map = createMap(t);
485485
const point = new Point(containerWidth / 2, containerHeight / 2);
486486
const options = {offset: {
487487
'bottom': [0, 0],
488488
'top': [0, 0]
489-
}, stickyAnchor: 'left'};
489+
}, anchorPreference: 'left'};
490490
const popup = new Popup(options)
491491
.setLngLat([0, 0])
492492
.setText('Test')

0 commit comments

Comments
 (0)