There are a lot of online magnifiers, so I wrote one myself because it is difficult to implement it. Below I will share with you the specific algorithms and implementation code, if you are interested, you can refer to a large number of restrictions on the Internet, which is hard to understand and troublesome ~ Write one by yourself. Laugh
Algorithm:
Step 1:
Position of the enlarged image = the width or height of the container where the mouse is located divided by the height and width of the container itself to find the percentage of the mouse moving in the container
Part 2:
After the percentage is obtained
X =-(x % * Image Width-display container width/2 );
Y =-(y % * Image Height-display container height/2 );
Two parameters, x and y, are the positions of the big image, followed by a display container size/2 to ensure that the image is displayed in the middle.
:
Code:
The Code is as follows:
Product Information