JSFiddle - React, Tailwind, and code Playground
by kougiland
HTML
<div id="drag"></div>
CSS
body {height:1000px; width:1000px;}
div {position:absolute; border:2px solid red;}
JavaScript
$(document).ready(function(){
$('#drag').css({
'height': ($(document).height()/10),
'width': ($(document).width()/10)
});
$("#drag").draggable({
scrollSensitivity: 50,
scrollSpeed: 10
});
$(window).scroll(function(){
if( $('#drag').offset().top < $(window).scrollTop() )
$("#drag").animate({top: $(window).scrollTop()}, "fast");
if( $('#drag').offset().left < $(window).scrollLeft() )
$("#drag").animate({left: $(window).scrollLeft()}, "fast");
});
});
var pressTimer
$("a").mouseup(function(){
clearTimeout(pressTimer)
// Clear timeout
return false;
}).mousedown(function(){
// Set timeout
pressTimer = window.setTimeout(function() { ... your code ...},1000)
return false;
});