Skip to content

Commit

Permalink
Use same code as orientation=auto for orientation=flip
Browse files Browse the repository at this point in the history
  • Loading branch information
plepe committed Dec 23, 2018
1 parent 9835d90 commit e830a4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The `text` parameter of `setText()` can either be:
* `offset` Set an offset to position text relative to the polyline (Default: 0)
* `orientation` Rotate text. (Default: 0)
- {orientation: angle} - rotate to a specified angle (e.g. {orientation: 15})
- {orientation: flip} - filps the text 180deg correction for upside down text placement on west -> east lines
- {orientation: flip} - flips the text 180deg correction for upside down text placement on west -> east lines
- {orientation: perpendicular} - places text at right angles to the line.
- {orientation: auto} - flips the text on (part of) ways running west to east, so that they are readable upside down.
* `allowCrop` If the line is short to display the whole text, crop the text. If false, don't show the text at all. (Default: true).
Expand Down
10 changes: 6 additions & 4 deletions leaflet.textpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,13 @@ var PolylineTextPath = {
} else {
finalText.push({ text: turnText(text), rotate: 180 });
}
} else if (options.orientation === 'flip') {
finalText.push({ text: turnText(text), rotate: 180 });
} else {
finalText = [ text ];
}
} else {
if (options.orientation === 'auto') {
if (options.orientation === 'auto' || options.orientation === 'flip') {
var textTurned = turnText(text)
}

Expand Down Expand Up @@ -190,6 +192,8 @@ var PolylineTextPath = {
} else {
finalText.push({ text: textTurned, rotate: 180 });
}
} else if (options.orientation === 'flip') {
finalText.push({ text: textTurned, rotate: 180 });
} else {
finalText.push(text);
}
Expand Down Expand Up @@ -227,13 +231,11 @@ var PolylineTextPath = {
if (options.orientation) {
var rotateAngle = 0;
switch (options.orientation) {
case 'flip':
rotateAngle = 180;
break;
case 'perpendicular':
rotateAngle = 90;
break;
case 'auto':
case 'flip':
rotateAngle = 0;
break;
default:
Expand Down

0 comments on commit e830a4d

Please sign in to comment.