Skip to content

Instantly share code, notes, and snippets.

@sungjaeHong
Created October 27, 2016 12:36
Show Gist options
  • Save sungjaeHong/d55314756c6957cc6d7e670653b43365 to your computer and use it in GitHub Desktop.
Save sungjaeHong/d55314756c6957cc6d7e670653b43365 to your computer and use it in GitHub Desktop.

#5-1

Promise를 쓰면 callback지옥에서 벗어난다는건 틀리다.
벗어날 수 있다는 것이지 무조건적으로 벗어난 다는 것이 아님.
인터프리터가 제어하는 것이 아닌 개발자가 제어할 수 있다는 장점이 있음.

##Drag & Drop event handler

let mousedown = e => {
	let startX = e.pageX, startY = e.pageY,
		mousemove = e => {
			let dX = e.pageX - offsetX, dY = e.pageY - offsetY;
		}, mouseup = e => {
			window.removeEventListener('mousemove', mousemove);
			window.removeEventListener('mouseup', mouseup);
		}
	window.addEventListener('mousemove', mousemove);
	window.addEventListener('mouseup', mouseup);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment