Skip to content

Instantly share code, notes, and snippets.

@zhang-ning
Forked from laughinghan/minimap.js
Last active August 29, 2015 14:26
Show Gist options
  • Save zhang-ning/98f44033940cc0481af3 to your computer and use it in GitHub Desktop.
Save zhang-ning/98f44033940cc0481af3 to your computer and use it in GitHub Desktop.
Minimap of a web page
javascript:
var minimap = document.body.cloneNode(true);
[].forEach.call(minimap.getElementsByTagName('a'), function(link) {
link.href = 'javascript:;';
});
minimap.style.position = 'fixed';
minimap.style.webkitTransform = 'scale(.1)';
document.body.appendChild(minimap);
minimap.style.top = minimap.offsetHeight*-.45+'px';
minimap.style.right = minimap.offsetWidth*-.45+'px';
minimap.onmousedown = function(e) {
document.body.scrollTop = 10*e.clientY-innerHeight/2;
document.onmousemove = arguments.callee;
document.onmouseup = function(){ document.onmousemove = null; };
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment