Click-to-move checkbox now works
This commit is contained in:
parent
d3eb8bb773
commit
2a52109c30
1 changed files with 26 additions and 21 deletions
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// TODO: Remember a position and restore that position
|
// TODO: Remember a position and restore that position
|
||||||
|
// TODO: Right click to auto-focus, centered on that region
|
||||||
|
|
||||||
// Key IDs
|
// Key IDs
|
||||||
var pgupKeyID = 33;
|
var pgupKeyID = 33;
|
||||||
|
|
@ -117,19 +118,33 @@
|
||||||
|
|
||||||
// Methods for input events
|
// Methods for input events
|
||||||
|
|
||||||
|
// Click-to-move
|
||||||
function clickHotspotImage(event) {
|
function clickHotspotImage(event) {
|
||||||
xCoordinate = event.offsetX;
|
if (document.getElementById("clickPositionCheck").checked == true) {
|
||||||
yCoordinate = event.offsetY;
|
xCoordinate = event.offsetX;
|
||||||
console.log(xCoordinate, yCoordinate)
|
yCoordinate = event.offsetY;
|
||||||
xRelative = (0.5*event.target.offsetWidth - xCoordinate)/event.target.offsetWidth;
|
console.log(xCoordinate, yCoordinate)
|
||||||
yRelative = (0.5*event.target.offsetHeight - yCoordinate)/event.target.offsetHeight;
|
xRelative = (0.5*event.target.offsetWidth - xCoordinate)/event.target.offsetWidth;
|
||||||
console.log(xRelative, yRelative)
|
yRelative = (0.5*event.target.offsetHeight - yCoordinate)/event.target.offsetHeight;
|
||||||
xSteps = xRelative * fovX;
|
console.log(xRelative, yRelative)
|
||||||
ySteps = yRelative * fovY;
|
xSteps = xRelative * fovX;
|
||||||
console.log(xSteps, ySteps, 0)
|
ySteps = yRelative * fovY;
|
||||||
moveStagePositions(xSteps, ySteps, 0)
|
console.log(xSteps, ySteps, 0)
|
||||||
|
moveStagePositions(xSteps, ySteps, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scroll-to-focus
|
||||||
|
window.addEventListener('wheel', function(e) {
|
||||||
|
multiplier = 1/100;
|
||||||
|
z_delta = e.deltaY * multiplier * focusVelocity;
|
||||||
|
console.log(z_delta);
|
||||||
|
if (document.getElementById("scrollFocusCheck").checked == true) {
|
||||||
|
// Make a position request
|
||||||
|
safeRequest("POST", "{{ url_for('position') }}", { "absolute": false, "z": z_delta}, keyMoveCallback)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
addEventListener("keydown", function (e) {
|
addEventListener("keydown", function (e) {
|
||||||
keysDown[e.keyCode] = true; //Add key to array
|
keysDown[e.keyCode] = true; //Add key to array
|
||||||
console.log(keysDown)
|
console.log(keysDown)
|
||||||
|
|
@ -169,16 +184,6 @@
|
||||||
delete keysDown[e.keyCode]; //Remove key from array
|
delete keysDown[e.keyCode]; //Remove key from array
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
window.addEventListener('wheel', function(e) {
|
|
||||||
multiplier = 1/100;
|
|
||||||
z_delta = e.deltaY * multiplier * focusVelocity;
|
|
||||||
console.log(z_delta);
|
|
||||||
if (document.getElementById("scrollFocusCheck").checked == true) {
|
|
||||||
// Make a position request
|
|
||||||
safeRequest("POST", "{{ url_for('position') }}", { "absolute": false, "z": z_delta}, keyMoveCallback)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Methods for making requests
|
// Methods for making requests
|
||||||
function safeRequest(method, url, payload, callback) {
|
function safeRequest(method, url, payload, callback) {
|
||||||
if (requestLock == false) {
|
if (requestLock == false) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue