INNER CODE UNIT · JavaScript

onStickTouchMove

CopterExpress/clover · apps/ios/cleverrc/main.js:56

function onStickTouchMove(touch) {
	var target = touch.target;
	var targetRect = target.getBoundingClientRect();
	var stickPointer = target.querySelector('.stick-pointer');

	var offsetX = touch.clientX - targetRect.left;
	var offsetY = touch.clientY - targetRect.top;

	var x = 2 * offsetX / targetRect.width;
	var y = 2 * offsetY / targetRect.height;

	x = Math.max(0, x);
	x = Math.min(2, x);
	y = Math.max(0, y);
	y = Math.min(2, y);

	stickPointer.style.left = (x * 50) + '%';
	stickPointer.style.top = (y * 50) + '%';

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…