Skip to content

Commit

Permalink
bar: added support for touch events
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 16, 2017
1 parent f70ace6 commit 9bf87a7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Tracy/assets/Bar/bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

forEach(elem.querySelectorAll('.tracy-icons a'), function(a) {
a.addEventListener('click', function(e) {
clearTimeout(elem.Tracy.displayTimeout);
if (this.rel === 'close') {
_this.toPeek();
} else {
Expand Down Expand Up @@ -235,6 +236,10 @@

} else if (this.rel) {
var panel = Debug.panels[this.rel];
if (panel.elem.dataset.tracyContent) {
panel.init();
}

if (e.shiftKey) {
panel.toFloat();
panel.toWindow();
Expand Down Expand Up @@ -487,8 +492,8 @@
started = true;
}

clientX = e.clientX;
clientY = e.clientY;
clientX = e.touches ? e.touches[0].clientX : e.clientX;
clientY = e.touches ? e.touches[0].clientY : e.clientY;
return false;
};

Expand All @@ -504,6 +509,8 @@
dragging = null;
dE.removeEventListener('mousemove', onMove);
dE.removeEventListener('mouseup', onEnd);
dE.removeEventListener('touchmove', onMove);
dE.removeEventListener('touchend', onEnd);
return false;
};

Expand All @@ -516,14 +523,16 @@
}

var pos = getPosition(elem);
clientX = e.clientX;
clientY = e.clientY;
clientX = e.touches ? e.touches[0].clientX : e.clientX;
clientY = e.touches ? e.touches[0].clientY : e.clientY;
deltaX = pos.right + clientX;
deltaY = pos.bottom + clientY;
dragging = true;
started = false;
dE.addEventListener('mousemove', onMove);
dE.addEventListener('mouseup', onEnd);
dE.addEventListener('touchmove', onMove);
dE.addEventListener('touchend', onEnd);
requestAnimationFrame(redraw);
if (options.start) {
options.start(e, elem);
Expand All @@ -532,6 +541,7 @@

forEach(options.handles, function (handle) {
handle.addEventListener('mousedown', onStart);
handle.addEventListener('touchstart', onStart);

handle.addEventListener('click', function(e) {
if (started) {
Expand Down

0 comments on commit 9bf87a7

Please sign in to comment.