C
C
Captain Cocoa2015-10-13 19:11:42
JavaScript
Captain Cocoa, 2015-10-13 19:11:42

Dragging a large image in a div, how to do it?

Hello everyone, there is a large picture map of the village.
On top of it, svg coordinates of houses are applied (when hovering, the roof changes color).
Now, in order to navigate the map, you need to use the horizontal and vertical scroll of the browser, this is very inconvenient.
Please tell me how to make it so that the map, along with the svg elements applied to it, can be dragged simply with the mouse (by analogy with Yandex / Google maps).

The code structure is this: jsfiddle.net/qa8vexdn

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Taratin, 2015-10-13
@RadCor

https://www.google.ru/search?q=javascript+drag+pan...
first link
codepen.io/JTParrett/pen/rkofB just add touch events.
second link https://asvd.github.io/dragscroll/

I
IceJOKER, 2015-10-13
@IceJOKER

add the whole thing to some div, give it a limited width | height and position relative, and to the inner block position absolute , then you can make it so that top and left change when you hover the mouse))
In the code, everything is too lazy to write

M
Maxim Martirosov, 2015-10-13
@kalbac

Try to implement it with SVG.js or Raphael.js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question