Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==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
You can’t perform that action at this time.