Skip to content

Instantly share code, notes, and snippets.

@hisasann
Created September 10, 2018 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hisasann/a2886e427280b22a184d84aad4c8a5f0 to your computer and use it in GitHub Desktop.
Save hisasann/a2886e427280b22a184d84aad4c8a5f0 to your computer and use it in GitHub Desktop.
window.addEventListener('load', function(){
navigator.mediaDevices.getUserMedia({audio: false, video: true}).then((stream) => {
const video = document.createElement('video');
video.id = 'drag';
video.draggable=true;
document.body.appendChild(video);
video.src=window.URL.createObjectURL(stream);
video.style='position: absolute; left: 10px; top: 10px; max-width: 300px; max-height: 300px; border: 1vmin solid white; z-index:99999;';
video.play();
var drag = document.querySelector('#drag');
console.log(drag);
drag.addEventListener('dragend', function(evt) {
drag.style.left = (evt.clientX - 150) +'px';
drag.style.top = (evt.clientY - 150) +'px';
}, true);
});
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment