Please cache the result to `pageOffsetTop(currentId)` as you call it on the `else if` again maybe.