This article mainly introduces the simple image floating effect implemented by js. It analyzes the method of using javascript to implement the function of regular floating movement of images in the form of a complete example, involving related techniques related to javascript timing functions and numerical dynamic operations, if you need it, you can refer to the examples in this article to describe the simple image floating effect implemented by js. We will share this with you for your reference. The details are as follows:
Use the window object to realize the floating effect of an image
1. An existing advertisement p is what we need to control. Its starting point is (0, 0)
2. Set the horizontal and vertical speed
3. Control advertisement p mobile
1) whether ad p reaches the Boundary
2) After reaching the boundary, we will set the speed to move backwards.
Untitled document