created sliding function and saves state of movement in object