Use jquery to create a sweeping robot animation. The animation effect is that the left side of the screen is some rubbish, then the picture is a sweeping robot, sweeping robot from the right to the left, and then swept the rubbish will be sucked into the sweep of the robot and disappeared.
Theory: By judging the relationship between the coordinates of the garbage element and the sweep robot's coordinates, it is judged whether the rubbish has been swept by the sweeping robot, and then the rubbish swept away will be hidden.
The principle of implementation: Use the Animate () function of jquery to make a small move, and then use the callback callback function of animate (), each time you move to determine whether the garbage has been swept by the sweep robot, the garbage swept away will be hidden. The function is then put into a timer to execute, using the SetInterval function, you can adjust the time to make the animation smooth. If the sweep robot finishes sweeping, turn off the timer.
Note: If you need to repeat execution from scratch after the animation has been performed, be aware that the last timer that was cleaned up will open normally the second time it is run.
Animation principle of sweeping robot