Yeah, the problem in the posted code is...
- When the X position is < -10, you set it to the right edge
- Then, you immediately see if the value is equal to the right edge (which it will be immediately after a left-edge wrap) and set it back to 0 if so.
If you use the code posted in the link I mentioned, you won't have this problem. Essentially, you want this (based on the code you posted):
position.x = wrapf(position.x, -10, getviewport_rect().size.x)