Skip to content

Instantly share code, notes, and snippets.

@arikui
Created May 5, 2013 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arikui/5520920 to your computer and use it in GitHub Desktop.
Save arikui/5520920 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Dashboard Drag Scroll
// @namespace http://d.hatena.ne.jp/arikui/
// @include http://www.tumblr.com/dashboard
// @include http://www.tumblr.com/tumblelog/*
// @grunt none
// ==/UserScript==
var position = {
mutable: false,
prev : null,
rato : 14
};
document.addEventListener("mousedown", function(event){
event.preventDefault();
event.stopPropagation();
var targetId = event.target.getAttribute("id");
if(event.target.tagName != "HTML"){
if(!targetId || !targetId.match(/^(?:dashboard_index|container|content)$/))
return;
}
position.mutable = true;
position.prev = event.clientY;
}, false);
document.addEventListener("mouseup", function(event){
event.preventDefault();
event.stopPropagation();
position.mutable = false;
}, false);
document.addEventListener("mousemove", function(event){
event.preventDefault();
event.stopPropagation();
if(!position.mutable)
return;
window.scrollBy(0, - position.rato * (event.clientY - position.prev));
position.prev = event.clientY;
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment