Line data Source code
1 : export type LayerDropPos = 'above' | 'below'
2 :
3 0 : export function dropPositionFor(ratio: number): LayerDropPos {
4 0 : return ratio < 0.5 ? 'above' : 'below'
5 : }
6 :
7 0 : export function reorderDropIndex(
8 : bottomUpIds: readonly string[],
9 : targetId: string,
10 : pos: LayerDropPos,
11 : offset: number
12 : ): number | null {
13 0 : const index = bottomUpIds.indexOf(targetId)
14 0 : if (index === -1) return null
15 0 : return offset + (pos === 'above' ? index + 1 : index)
16 : }
|