Maybe by linking the Trim Path to linear interpolation, which is controlled by x position, while moving left or right?
Something like this to Trim Path value.
linear(yourLayer.transform.position[0], 0, thisComp.width, 0, 100)
Find out more:
After Effects Tutorials: motion design, expressions, scripting.