Skip to content

Instantly share code, notes, and snippets.

@yudenzel
Last active September 2, 2020 03:04
Show Gist options
  • Select an option

  • Save yudenzel/ee54671c9f253d1be41b04102138cbaa to your computer and use it in GitHub Desktop.

Select an option

Save yudenzel/ee54671c9f253d1be41b04102138cbaa to your computer and use it in GitHub Desktop.
A helper tampermonkey script allows drag the sketch document.
// ==UserScript==
// @name Sketch Measure Helper
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match file://*/*
// @grant none
// @run-at document-idle
// ==/UserScript==
(function () {
var target = jQuery(".screen-viewer")
target.on("mousedown.sketch-measure-helper", function(e) {
var MOUSE_BUTTON_LEFT = 0
if(e.button !== MOUSE_BUTTON_LEFT) return false;
var initX = parseInt(target.scrollLeft()) || 0;
var initY = parseInt(target.scrollTop()) || 0;
var downX = e.clientX;
var downY = e.clientY;
target.on("mousemove.sketch-measure-helper", function(e) {
var left = initX + downX - e.clientX
var top = initY + downY - e.clientY
target.scrollLeft(left);
target.scrollTop(top);
e.preventDefault();
});
target.on("mouseup.sketch-measure-helper",function() {
target.off("mousemove.sketch-measure-helper");
target.off("mouseup.sketch-measure-helper");
e.preventDefault();
});
e.preventDefault();
return true;
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment