Skip to content

Commit

Permalink
Favor previous anchor only when still available
Browse files Browse the repository at this point in the history
  • Loading branch information
Asheem Mamoowala committed Jul 13, 2019
1 parent be7e27f commit 36c1593
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/symbol/placement.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export class Placement {
// anchor to the front of the anchor list.
if (this.prevPlacement && this.prevPlacement.variableOffsets[symbolInstance.crossTileID]) {
const prevOffsets = this.prevPlacement.variableOffsets[symbolInstance.crossTileID];
if (anchors[0] !== prevOffsets.anchor) {
if (anchors[0] !== prevOffsets.anchor && anchors.indexOf(prevOffsets.anchor) >= 0) {
anchors = anchors.filter(anchor => anchor !== prevOffsets.anchor);
anchors.unshift(prevOffsets.anchor);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"version": 8,
"metadata": {
"test": {
"width": 64,
"height": 64,
"operations": [
[
"setLayoutProperty",
"symbol",
"text-variable-anchor",
["bottom"]
],
[
"wait"
]
]
}
},
"transition": {
"duration": 0
},
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
}
]
}
}
},
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
"layers": [
{
"id": "symbol",
"type": "symbol",
"source": "geojson",
"layout": {
"text-variable-anchor": ["left"],
"text-field": "ABC",
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
],
"symbol-placement": "point"
},
"paint": {
"text-color": "red"
}
},
{
"id" : "dot",
"type": "circle",
"source": "geojson",
"paint": {
"circle-color": "red"
}

}
]
}

0 comments on commit 36c1593

Please sign in to comment.