Ok, try initiating onDrag outside of initDragEvents() like so:
//......
let onDrag; // Initiate onDrag here. If you want to you could move the logic here as well but it shouldn't be neccesary, I think.
function initDragEvents() {
if (BANGLEJS2) {
//Bangle.on("drag", e => {
onDrag = e => { // Add logic to onDrag here as before. Notice I dropped the "let" on this line.
//......
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Ok, try initiating
onDrag
outside ofinitDragEvents()
like so: