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

Attempting to get the original target for click events #2037

Merged
merged 3 commits into from
Sep 27, 2021
Merged

Conversation

iangilman
Copy link
Member

@iangilman iangilman commented Sep 20, 2021

Fixes #1997

Here's my attempt to fix #1997, but it doesn't seem to be working. Here's my test code (for use in test/demo/basic.html):

var viewer = OpenSeadragon({
    id: "contentDiv",
    prefixUrl: "../../build/openseadragon/images/",
    tileSources: "../data/testpattern.dzi",
});

viewer.addHandler("open", function(event) {
    var elt = elt = document.createElement("div");
    elt.className = "runtime-overlay";
    elt.style.background = "white";
    elt.style.outline = "3px solid red";
    elt.style.width = "100px";
    elt.textContent = "Open console and click on me";
    viewer.addOverlay({
        element: elt,
        location: new OpenSeadragon.Point(0.6, 0.6),
        height: 0.1,
        placement: OpenSeadragon.Placement.TOP_LEFT,
        rotationMode: OpenSeadragon.OverlayRotationMode.NO_ROTATION
    });

});

viewer.addHandler('canvas-click', function(event) {
    console.log(event);
});

When I run it and click on the overlay, the event that's logged has an originalTarget but it's div.openseadragon-canvas (whereas we want it to be div.runtime-overlay).

I've tried doing console.log on the event during pointerDown handling, and those events are all in terms of the canvas. I'm not sure where to get the overlay, and why it's not showing up in the event.

@msalsbery do you have any insights on this?

@iangilman
Copy link
Member Author

@msalsbery I've added documentation for the new property. I also went ahead and fixed the spelling of isStoppable, since I was in there :)

Copy link
Member

@msalsbery msalsbery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@@ -1191,7 +1193,7 @@
* the emulated event, a synthetic event object created with values from the actual DOM event,
* or null if no DOM event applies. Emulated events can occur on eventType "wheel" on legacy mouse-scroll
* event emitting user agents.
* @property {Boolean} isStopable
* @property {Boolean} isStoppable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix! ;-)

@msalsbery msalsbery added this to the 3.0.0 milestone Sep 23, 2021
@iangilman iangilman marked this pull request as ready for review September 24, 2021 02:16
@iangilman
Copy link
Member Author

Great, thank you for the review!

@iangilman iangilman merged commit 8e20ac8 into master Sep 27, 2021
@iangilman iangilman deleted the ig-event branch September 27, 2021 18:26
iangilman added a commit that referenced this pull request Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: track the original target in canvas-click
2 participants