guess -= dir here?
Otherwise, you're calling relativeVisiblityPosition() twice on the same index, right?