Prevent player movement mid-air (without teleport)

Is there a way to prevent players from moving on the x/z axis while mid-air? (for example while under the levitation effect) I've tried using the slowness effect as well as the movement_speed attribute but neither worked unless the player is on ground
Continue to help post