Found solution in this post: Detect which element flex-wrap affects. Using getBoundingClientRect() found difference of 'top' between current and next word and by that got the index of last word in-line.