| 1 |
import placements from '../methods/placements'; |
| 2 |
|
| 3 |
// Get rid of `auto` `auto-start` and `auto-end` |
| 4 |
const validPlacements = placements.slice(3); |
| 5 |
|
| 6 |
/** |
| 7 |
* Given an initial placement, returns all the subsequent placements |
| 8 |
* clockwise (or counter-clockwise). |
| 9 |
* |
| 10 |
* @method |
| 11 |
* @memberof Popper.Utils |
| 12 |
* @argument {String} placement - A valid placement (it accepts variations) |
| 13 |
* @argument {Boolean} counter - Set to true to walk the placements counterclockwise |
| 14 |
* @returns {Array} placements including their variations |
| 15 |
*/ |
| 16 |
export default function clockwise(placement, counter = false) { |
| 17 |
const index = validPlacements.indexOf(placement); |
| 18 |
const arr = validPlacements |
| 19 |
.slice(index + 1) |
| 20 |
.concat(validPlacements.slice(0, index)); |
| 21 |
return counter ? arr.reverse() : arr; |
| 22 |
} |