Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for panel drag. #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions screenlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var logEl,
isInitialized = false,
_console = {}; // backup console obj to contain references of overridden fns.
_console = {}, // backup console obj to contain references of overridden fns.
_options = {
bgColor: 'black',
logColor: 'lightgreen',
Expand All @@ -11,7 +11,8 @@
errorColor: 'red',
freeConsole: false,
css: '',
autoScroll: true
autoScroll: true,
draggable: true
};

function createElement(tag, css) {
Expand All @@ -22,6 +23,17 @@

function createPanel() {
var div = createElement('div', 'z-index:2147483647;font-family:Helvetica,Arial,sans-serif;font-size:10px;font-weight:bold;padding:5px;text-align:left;opacity:0.8;position:fixed;right:0;top:0;min-width:200px;max-height:50vh;overflow:auto;background:' + _options.bgColor + ';' + _options.css);

if(_options.draggable) {
div.onmousedown = function(e) {
var offsetX = this.offsetLeft - e.clientX;
var offsetY = this.offsetTop - e.clientY;

this.onmousemove = function(e) { this.style.top = (e.clientY + offsetY) + "px"; this.style.right = (window.innerWidth - (e.clientX + offsetX + this.offsetWidth)) + "px"; };
};
div.onmouseup = function(e) { this.onmousemove = null; };
}

return div;
}

Expand Down