function touch2() {
  Bangle.on("touch", (side, xy) => {
    const ar = Bangle.appRect;
    if (xy.x<ar.x+ar.w/3) {
      pausePrev();
    } else if (xy.x>ar.x+ar.w*2/3) {
      nextPlay();
    } else {
      togglePlay();
    }
  });
  // swiping
  let drag;
  Bangle.on("drag", e => {
    if (!drag) { // start dragging
      drag = {x: e.x, y: e.y};
    } else if (!e.b) { // released
      const dx = e.x-drag.x, dy = e.y-drag.y;
      drag = null;
      if (Math.abs(dx)>Math.abs(dy)+10) {
        // horizontal
        sendCommand(dx>0 ? "previous" : "next");
      } else if (Math.abs(dy)>Math.abs(dx)+10) {
        // vertical
        sendCommand(dy>0 ? "volumedown" : "volumeup");
      }
    }
  });
}
/**
 * Setup touch+swipe for Bangle.js 2
 */
Setup touch+swipe for Bangle.js 2
Setup touch + swipe for Bangle . js 2
function touch2() {
  Bangle.on("touch", (side, xy) => {
    const ar = Bangle.appRect;
    if (xy.x<ar.x+ar.w/3) {
      pausePrev();
    } else if (xy.x>ar.x+ar.w*2/3) {
      nextPlay();
    } else {
      togglePlay();
    }
  });
  let drag;
  Bangle.on("drag", e => {
    if (!drag) { 
      drag = {x: e.x, y: e.y};
    } else if (!e.b) { 
      const dx = e.x-drag.x, dy = e.y-drag.y;
      drag = null;
      if (Math.abs(dx)>Math.abs(dy)+10) {
        sendCommand(dx>0 ? "previous" : "next");
      } else if (Math.abs(dy)>Math.abs(dx)+10) {
        sendCommand(dy>0 ? "volumedown" : "volumeup");
      }
    }
  });
}
function touch2 ( ) { Bangle . on ( "touch" , ( side , xy ) => { const ar = Bangle . appRect ; if ( xy . x < ar . x + ar . w / 3 ) { pausePrev ( ) ; } else if ( xy . x > ar . x + ar . w * 2 / 3 ) { nextPlay ( ) ; } else { togglePlay ( ) ; } } ) ; let drag ; Bangle . on ( "drag" , e => { if ( ! drag ) { drag = { x : e . x , y : e . y } ; } else if ( ! e . b ) { const dx = e . x - drag . x , dy = e . y - drag . y ; drag = null ; if ( Math . abs ( dx ) > Math . abs ( dy ) + 10 ) { sendCommand ( dx > 0 ? "previous" : "next" ) ; } else if ( Math . abs ( dy ) > Math . abs ( dx ) + 10 ) { sendCommand ( dy > 0 ? "volumedown" : "volumeup" ) ; } } } ) ; }
Setup touch+swipe for Bangle.js 2
Setup touch + swipe for Bangle . js 2
// swiping // start dragging // released // horizontal // vertical