Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
fixed a minor bug (after hovering over an object with link, clicking on white space will also trigger jumping to another page)
  • Loading branch information
quez-fun authored Jun 14, 2024
1 parent 5388b06 commit 75210c3
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ <h4>My Projects</h4>
};

let initialAnimation = true;
let oldPickNdx = -1;
let oldPickNdx = -1, isPicked = false;

//create frame buffer
const targetTexture = gl.createTexture();
Expand Down Expand Up @@ -345,23 +345,25 @@ <h4>My Projects</h4>
const pixels = new Uint8Array(4);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixels);

if (pixels[3] > 0) {
if (pixels[3] > 0) {

const pickNdx = (pixels[0] - 1) * rowNum + pixels[1];
const pickNdx = (pixels[0] - 1) * rowNum + pixels[1];

if (pickNdx == 9) {
tag.style.display = 'block';

tag.style.left = e.clientX - 35 + 'px';
tag.style.top = e.clientY - 50 + 'px';
tag.innerHTML = 'visit gallery';
window.addEventListener('mousedown', pageJump, false);
} else {
tag.style.display = 'none';
window.removeEventListener('mousedown', pageJump, false);
}
if (pickNdx == 9) {
tag.style.display = 'block';

tag.style.left = e.clientX - 35 + 'px';
tag.style.top = e.clientY - 50 + 'px';
tag.innerHTML = 'visit gallery';

isPicked = true;

} else {
tag.style.display = 'none';
isPicked = false;
}

if (oldPickNdx < 0) {
if (oldPickNdx < 0) {

objects[(pickNdx - 1) * 4].colorUniforms.u_colorMult = [0.5, 0.3, 0.8, 0.55];
objects[(pickNdx - 1) * 4 + 1].colorUniforms.u_colorMult = [0.5, 0.3, 0.8, 0.55];
Expand All @@ -372,7 +374,7 @@ <h4>My Projects</h4>

drawScene();

} else {
} else {

if (oldPickNdx !== pickNdx) {

Expand Down Expand Up @@ -407,6 +409,7 @@ <h4>My Projects</h4>
oldPickNdx = -1;

tag.style.display = 'none';
isPicked = false;

}

Expand Down Expand Up @@ -530,6 +533,8 @@ <h4>My Projects</h4>

window.addEventListener('resize', drawScene, false);
window.addEventListener('mousemove', renderPicking, false);

window.addEventListener('mousedown', pageJump, false);
}

}
Expand Down Expand Up @@ -557,7 +562,11 @@ <h4>My Projects</h4>
}

function pageJump() {
window.location.href = "https://quez-fun.github.io/gallery.html";

if (isPicked) {
window.location.href = "https://quez-fun.github.io/gallery.html";
}

}

main();
Expand Down

0 comments on commit 75210c3

Please sign in to comment.