I'm trying to replicate as closely as possible the sliding toggles of iOS, using just JS and CSS. I've found the excellent pen by @3rror404 that does exactly that here.
While it works perfectly in iOS Safari , it does react just to clicks and not to drags in Chrome (both Desktop and Android) and I don't understand why. I even added mouseup/mousedown/mousemove events, but still a no go..
for (let i = 0; i < switches.length; i++) {
const switchEl = switches[i];
switchEl.draggable = true;
['dragstart', 'touchstart','mousedown'].forEach(function(e) {
switchEl.addEventListener(e, onDragStart);
});
['dragover', 'touchmove','mousemove'].forEach(function(e) {
switchEl.addEventListener(e, onDragOver);
});
['dragend', 'touchend','mouseup'].forEach(function(e) {
switchEl.addEventListener(e, onDragEnd);
});
}
see my edited pen here: https://codepen.io/azerty1234/pen/BajLqgN
any idea why this happens or possible fixes? Thanks!