-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathempathy.js
43 lines (33 loc) · 1.01 KB
/
empathy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
window.newElement = function (type, newClass, styles) {
var output = document.createElement(type);
if (typeof newClass != 'undefined') output.classList.add(newClass);
if (typeof styles != 'undefined') window.setStyles(output, styles);
return output;
};
function EmpathyBar () {
self = newElement('div', 'empathyBar');
self.appendChild(new ColorBlindnessSimulator(self));
self.load = function(){
qs('body').appendChild(this);
};
return self;
}
var empathy = new EmpathyBar();
empathy.load();
// Global mouse handling
window.mouseIsDown = false;
window.dragElement = null;
document.addEventListener('mousedown', function() {
if (event.target.isSlideHandle) {
window.dragElement = event.target;
}
});
document.addEventListener('mouseup', function () {
window.dragElement = null;
});
// For the comparison handle... feels hacky...
document.addEventListener('mousemove', function(event) {
if (window.dragElement) {
window.dragElement.move(event);
}
});