JSFiddle - React, Tailwind, and code Playground
by fredd man
HTML
<div class="page pinch-zoom-parent">
<div class="pinch-zoom">
<!-- DRAGABLE 3 -->
<!-- Draggable DIV -->
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<div id="mydiv12" class="js_zoom_and_pan">
<div id="mydivheader12"> Click Aqui para mover </div>
<script>
(function() {
function touchHandler(e) {
var touches = e.changedTouches;
var first = touches[0];
var type = "";
switch(e.type) {
case "touchstart":
type = "mousedown";
break;
case "touchmove":
type="mousemove";
break;
case "touchend":
type="mouseup";
break;
default:
return;
}
var simulatedEvent = document.createEvent("MouseEvent");
simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0, null);
first.target.dispatchEvent(simulatedEvent);
e.preventDefault();
}
function init() {
document.addEventListener("touchstart", touchHandler, true);
document.addEventListener("touchmove", touchHandler, true);
document.addEventListener("touchend", touchHandler, true);
document.addEventListener("touchcancel", touchHandler, true);
}
init();
})();
(function($) {
$.fn.drags = function(opt) {
opt = $.extend({handle:"",cursor:"move"}, opt);
if(opt.handle === "") {
var $el = this;
} else {
var $el = this.find(opt.handle);
}
return $el.css('cursor', opt.cursor).on("mousedown", function(e) {
if(opt.handle === "") {
var $drag = $(this).addClass('draggable');
} else {
var $drag = $(this).addClass('active-handle').parent().addClass('draggable');
}
var z_idx = $drag.css('z-index'),
drg_h = $drag.outerHeight(),
drg_w = $drag.outerWidth(),
pos_y =...
CSS
.pinch-zoom-parent {
height: 100vh;
width: 100%;
}
JavaScript
var el = document.querySelector('.pinch-zoom');
new PinchZoom.default(el, {});