C
C
Captain Cocoa2015-10-02 10:34:54
JavaScript
Captain Cocoa, 2015-10-02 10:34:54

How to drag and zoom a large image in an overflow:hidden div?

Good morning everyone, there is a picture of a map of a residential village, it’s big there, something like 8000px by 5000px.
I need to insert it into a div and make it so that a person can zoom in, zoom out, and scroll, but it’s better to drag the cursor to the left to the right to She moved (like a finger on a tablet).
You can achieve the effect of scrolling on pure css through overflow:auto:
But how to zoom it and drag it with the cursor, that's the question.
Tell me how to implement this, or perhaps there are ready-made libraries for this.

23dbfbee3e5c4e1f98431a5033a978c8.jpg

Sample code: jsfiddle.net/ds9q4h2c

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
littleguga, 2015-10-02
@littleguga

Here is the code for you . It does not go beyond the borders, the zoom on the scroll of the mouse and in general everything is wonderful.
Rewrote the code, now it's better. True without zoom:
https://jsfiddle.net/littleguga/jveaparp/1/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question