Fix teleportation bug

The time variable was only set in drag events, so a mousedown followed by
mouseup would have an undefined time, which was messing up the math and setting
the position to NaN.