-
Notifications
You must be signed in to change notification settings - Fork 68
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
Enable touch events #83
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
left: 0; | ||
bottom: 45px; | ||
right: 0; | ||
touch-action: pan-x pan-y; | ||
} | ||
|
||
#pedalboard-dashboard.dev_api:after { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
|
||
<script type="text/javascript" src="js/lib/jquery-1.9.1.min.js?v={{version}}"></script> | ||
<script type="text/javascript" src="js/lib/jquery-ui-1.10.1.custom.min.js?v={{version}}"></script> | ||
<script> if (! ("ontouchend" in document)){document.ontouchend=''}</script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it turns out |
||
<script type="text/javascript" src="js/lib/jquery.ui.touch-punch.min.js?v={{version}}"></script> | ||
<script type="text/javascript" src="js/lib/jquery.ba-resize.min.js?v={{version}}"></script> | ||
<script type="text/javascript" src="js/lib/mustache.js?v={{version}}"></script> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -532,31 +532,31 @@ function Desktop(elements) { | |
removeBPMHardwareMapping: function(syncMode) { | ||
var instanceAndSymbol = "/pedalboard/:bpm" | ||
if (self.hardwareManager.removeHardwareMappping(instanceAndSymbol)) { | ||
var source = syncMode === "link" ? "Ableton Link" : "MIDI" | ||
new Notification('info', 'BPM addressing removed, incompatible with ' + source + ' sync mode', 8000) | ||
} | ||
self.pedalboardModified = true | ||
var source = syncMode === "link" ? "Ableton Link" : "MIDI" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems somene has different editor settings for spaces/tabs. Suggest you use Also, for some reason even though I fetch and merged your upstream changes this was left out. I triple checked it is in your master. |
||
new Notification('info', 'BPM addressing removed, incompatible with ' + source + ' sync mode', 8000) | ||
} | ||
self.pedalboardModified = true | ||
}, | ||
setSyncMode: function(syncMode, callback) { | ||
$.ajax({ | ||
url: '/pedalboard/transport/set_sync_mode/' + syncMode, | ||
type: 'POST', | ||
success: function (resp) { | ||
if (resp) { | ||
callback(true) | ||
} else { | ||
new Bug("Couldn't set new sync mode") | ||
callback(false) | ||
} | ||
}, | ||
error: function () { | ||
new Bug("Couldn't set new sync mode, server error") | ||
callback(false) | ||
}, | ||
cache: false, | ||
dataType: 'json' | ||
url: '/pedalboard/transport/set_sync_mode/' + syncMode, | ||
type: 'POST', | ||
success: function (resp) { | ||
if (resp) { | ||
callback(true) | ||
} else { | ||
new Bug("Couldn't set new sync mode") | ||
callback(false) | ||
} | ||
}, | ||
error: function () { | ||
new Bug("Couldn't set new sync mode, server error") | ||
callback(false) | ||
}, | ||
cache: false, | ||
dataType: 'json' | ||
}) | ||
}, | ||
}, | ||
unaddressPort: function (portSymbol, syncMode, callback) { | ||
var addressing = { | ||
uri : kNullAddressURI, | ||
|
@@ -672,7 +672,7 @@ function Desktop(elements) { | |
}), | ||
success: function (resp) { | ||
if (! resp.result) { | ||
callback(false) | ||
callback(false) | ||
return | ||
} | ||
callback(true) | ||
|
@@ -1269,15 +1269,15 @@ function Desktop(elements) { | |
} | ||
}) | ||
|
||
elements.settingsIcon.click(function() { | ||
document.location.href = '/settings'; | ||
}) | ||
elements.settingsIcon.click(function() { | ||
document.location.href = '/settings'; | ||
}) | ||
|
||
elements.settingsIcon.statusTooltip() | ||
elements.pedalboardTrigger.statusTooltip() | ||
elements.pedalboardBoxTrigger.statusTooltip() | ||
elements.bankBoxTrigger.statusTooltip() | ||
elements.cloudPluginBoxTrigger.statusTooltip() | ||
elements.settingsIcon.statusTooltip() | ||
elements.pedalboardTrigger.statusTooltip() | ||
elements.pedalboardBoxTrigger.statusTooltip() | ||
elements.bankBoxTrigger.statusTooltip() | ||
elements.cloudPluginBoxTrigger.statusTooltip() | ||
|
||
this.upgradeWindow = elements.upgradeWindow.upgradeWindow({ | ||
icon: elements.upgradeIcon, | ||
|
@@ -1304,9 +1304,9 @@ function Desktop(elements) { | |
var prevent = function (ev) { | ||
ev.preventDefault() | ||
} | ||
|
||
$('body')[0].addEventListener('gesturestart', prevent) | ||
$('body')[0].addEventListener('gesturechange', prevent) | ||
$('body')[0].addEventListener('touchmove', prevent) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is right pain. Should use {passive: false} to make it actually work and then older browser will mis interpret that as another option.. Chrome automatically assume ignore, but not firefox. Both throw warnings if don;t use passive:false unless use |
||
$('body')[0].addEventListener('dblclick', prevent) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,7 +239,7 @@ JqueryClass('pedalboard', { | |
}}); | ||
|
||
// Dragging the pedalboard move the view area | ||
self.mousedown(function (e) { | ||
self.bind('mousedown touchstart', function (e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so |
||
self.pedalboard('drag', e) | ||
}) | ||
|
||
|
@@ -726,6 +726,18 @@ JqueryClass('pedalboard', { | |
|
||
var scale = self.data('scale') | ||
|
||
// pure side effects - update the event if touch | ||
function patchTouchEvent(e) { | ||
if (e.type.indexOf('touch') == 0) { | ||
var touch = e.originalEvent.touches[0] | ||
e.pageX = touch.pageX | ||
e.pageY = touch.pageY | ||
} | ||
return e | ||
} | ||
|
||
start = patchTouchEvent(start) | ||
|
||
var canvasX = (start.pageX - self.offset().left) / scale | ||
var canvasY = (start.pageY - self.offset().top) / scale | ||
var screenX = start.pageX - self.parent().offset().left | ||
|
@@ -735,19 +747,21 @@ JqueryClass('pedalboard', { | |
if (self.data('preventDrag')) | ||
return | ||
|
||
e = patchTouchEvent(e) | ||
|
||
self.pedalboard('zoom', scale, canvasX, canvasY, | ||
screenX + e.pageX - start.pageX, | ||
screenY + e.pageY - start.pageY, | ||
0) | ||
} | ||
|
||
var upHandler = function (e) { | ||
$(document).unbind('mouseup', upHandler) | ||
$(document).unbind('mousemove', moveHandler) | ||
$(document).unbind('mouseup touchend', upHandler) | ||
$(document).unbind('mousemove touchmove', moveHandler) | ||
} | ||
|
||
$(document).bind('mousemove', moveHandler) | ||
$(document).bind('mouseup', upHandler) | ||
$(document).bind('mousemove touchmove', moveHandler) | ||
$(document).bind('mouseup touchend', upHandler) | ||
}, | ||
|
||
// Changes the viewing scale of the pedalboard and position it in a way that | ||
|
@@ -1352,13 +1366,13 @@ JqueryClass('pedalboard', { | |
} | ||
} | ||
|
||
icon.mousedown(function () { | ||
icon.bind('mousedown touchstart', function () { | ||
self.pedalboard('preventDrag', true) | ||
var upHandler = function () { | ||
self.pedalboard('preventDrag', false) | ||
$('body').unbind('mouseup', upHandler) | ||
$('body').unbind('mouseup touchend', upHandler) | ||
} | ||
$('body').bind('mouseup', upHandler) | ||
$('body').bind('mouseup touchend', upHandler) | ||
}) | ||
|
||
var actions = $('<div>').addClass('mod-actions').appendTo(icon) | ||
|
@@ -1462,7 +1476,7 @@ JqueryClass('pedalboard', { | |
gui.disable(symbol) | ||
} else { | ||
gui.addressPort(symbol) | ||
} | ||
} | ||
} | ||
|
||
self.pedalboard('addUniqueCallbackToArrive', cb, targetname1, callbackId) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stop browser handling these events as the code does.