I needed a simple way to implement dragging and scroll wheel zooming on an HTML canvas, but I couldn't find a pure JS example. The most popular one uses an SVG node to convert coordinates, but I didn't like that so I created my own version.
Try it here: https://jsfiddle.net/balazsbotond/6n2uzjkq/30/