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

Enable touch events #83

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions html/css/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
left: 0;
bottom: 45px;
right: 0;
touch-action: pan-x pan-y;
Copy link
Author

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.

}

#pedalboard-dashboard.dev_api:after {
Expand Down
1 change: 1 addition & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it turns out jquery.ui.touch-punch.min.js is broken as it checks for this and bails out if not set. No idea why. Perhaps an old touch events thing or only certain browsers? Who knows.

<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>
Expand Down
62 changes: 31 additions & 31 deletions html/js/desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Author

@SteveALee SteveALee Aug 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems somene has different editor settings for spaces/tabs. Suggest you use editorconfig. or prettier

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,
Expand Down Expand Up @@ -672,7 +672,7 @@ function Desktop(elements) {
}),
success: function (resp) {
if (! resp.result) {
callback(false)
callback(false)
return
}
callback(true)
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Copy link
Author

Choose a reason for hiding this comment

The 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 touch-action in css, which I did

$('body')[0].addEventListener('dblclick', prevent)
}

Expand Down
32 changes: 23 additions & 9 deletions html/js/pedalboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ JqueryClass('pedalboard', {
}});

// Dragging the pedalboard move the view area
self.mousedown(function (e) {
self.bind('mousedown touchstart', function (e) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so jquery.ui.touch-punch.min.js is not working for the desktop - we have to do the equivalent our selvess - not hard.

self.pedalboard('drag', e)
})

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1462,7 +1476,7 @@ JqueryClass('pedalboard', {
gui.disable(symbol)
} else {
gui.addressPort(symbol)
}
}
}

self.pedalboard('addUniqueCallbackToArrive', cb, targetname1, callbackId)
Expand Down