Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div class="child">Start by pressing down on this box and moving your mouse for some time</div>
</body>
</html>
 
.child {
  background: lightBlue;
  width: 300px;
  height: 100px;
}
 
/* 
 * NB!
 * Enable Mobile Emulation on Chrome to test this!
 */
var childElement = document.querySelector('.child');
function move() {
  console.log('touchmove');
}
function cancel() {
  console.log('touchcancel');
}
function start() {
  console.log('start');
  setTimeout(function () {
    childElement.parentElement.removeChild(childElement);
    console.log('Removed element, move events stopped');
    var event = document.createEvent('TouchEvent');
    event.initUIEvent('touchstart', true, true);
    document.body.dispatchEvent(event);
    event = document.createEvent('TouchEvent');
    event.initUIEvent('touchmove', true, true);
    document.body.dispatchEvent(event);
  }, 1000);
}
document.body.addEventListener('touchmove', move);
document.body.addEventListener('touchcancel', cancel);
document.body.addEventListener('touchstart', start);
childElement.addEventListener('touchstart', start);
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers