Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is difference between cursor and stone position when edit mode of BasicPlayer. #85

Open
swdrsk opened this issue Jun 8, 2017 · 1 comment

Comments

@swdrsk
Copy link

swdrsk commented Jun 8, 2017

I think getMousePos() in wgo.js is incorrect.
(wgo.js (line: 1151))
e.layerX, e.layerY get negative values or huge values, depended on browser expansion rate and element width.
It may be bug.

thanks

@swdrsk
Copy link
Author

swdrsk commented Jun 9, 2017

var getMousePos = function(e) {
	// new hopefully better translation of coordinates
	var element = this.element, offsetX = 0, offsetY = 0;

	if (element.offsetParent) {
		do {
			offsetX += element.offsetLeft;
			offsetY += element.offsetTop;
		} while ((element = element.offsetParent));
	}

	var mx = e.pageX - offsetX;
	var my = e.pageY - offsetY

	var x, y;

	x = mx * this.pixelRatio;
	x -= this.left;
	x /= this.fieldWidth;
	x = Math.round(x);

	y = my * this.pixelRatio;
	y -= this.top;
	y /= this.fieldHeight;
	y = Math.round(y);

	return {
		x: x >= this.size ? -1 : x,
		y: y >= this.size ? -1 : y
	};
}

This will be better, I think.
https://stackoverflow.com/questions/3584357/incorrect-layerx-layery-values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant