How can I 'lock' the position of an object when applying curve displacement? I'm trying to simulate quickly the waving of a flag by deforming it with a curve modifier and moving that modifier along it's local x-axis, giving the impression that it's waving and allowing it to be easily looped. However, moving the curve also shifts the position of the 'fabric' around. Images below:

Before moving the curve:



After moving the curve:



So in the second image I would like the flag to remain aligned to the pole, but with a different displacement. How can I resolve this?

Thanks.
I recommend using the [Wave Modifier] for various reasons including


The Wave Modifier is often used for this purpose.  Its purpose is very clear.
Your curve above may not be long enough for longer repetitive motion and the endpoints tangents could affect the final result.
The difficulty you are already experiencing
The Wave Modifier has a [falloff] to keep the flag attached to the pole.  No Pun Intended. The selected empty serves this purpose in the image above.
As an alternative that you can create a vertex group to limit the vertex movement on the flag mesh near the pole, to zero.
As a [Not Recommended] alternative you could animate the curve rather than moving it.