If the Java code is in the middle of a fling when Gecko sends a viewport update, abort the fling, cancel the velocity, and re-fling. The re-fling is purely to get the page snapped to an edge if needed.