question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to make overlay recognized as linked class

See original GitHub issue

Demo: https://chattanoogahistory.com/HTML5-boilerplate/clicktest.php

Using OpenSeadragonHTMLelements.js to position SVG(s) over specific locations in canvas. I use classes to link/open other .dzi’s This works well for other elements, such as the button labeled ‘INDEX’. However, the red SVG has the same class assigned, but does not react to a click. I suspect a JavaScript issue, but cannot figure it out.

Any assistance would be greatly appreciated.

Code that links and opens other dzi:

// 16
$(document).on('click', '.loc16', function() {
	viewer.open([{
		tileSource: loc16
	}]);
	$("#div1").text("Plate 16");
	setTimeout(function() {
		viewer.viewport.fitBounds(box1);
	}, 400);
});

Overlay that is assigned the same class, but not clickable:

	var hEl = viewer.HTMLelements()	 
	var img = document.createElement('img')
    img.src = 'https://chattanoogahistory.com/svg/16.svg';	
	img.style.backgroundColor = 'rgba(255,0,0,0.2)'
	img.style.borderRadius = '50%'
	img.className = "loc16";

	 hEl.addElement({
            id: "loc16",
            element: img,
            x: 4600,
            y: 3300,
            width: 300,
            height: 300
          })

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Aiosacommented, Dec 29, 2022

@pearcetm Aha! Anyway, I updated the docs so that we have it documented. Thank you.

1reaction
pearcetmcommented, Dec 29, 2022

Instead of using jQuery delegated events, try using a MouseTracker so your events aren’t eaten by the viewer’s event handling:

new OpenSeadragon.MouseTracker({
    element: yourElement,
    clickHandler: handlerFunc,
    ...
});

This should at least get you to the point where you are receiving the events. It will require a little refactoring of where you define the handler(s) but hopefully that won’t be too hard.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Overlay Techniques - Codrops
First, you need to make sure that the overlay is positioned absolutely with respect to the body . So, if the overlay is...
Read more >
How to overlay one div over another div - html - Stack Overflow
To do this, we'll wrap the .navi and #infoi elements in a new element <div class="wrapper"> so we can create a new position...
Read more >
How to overlay one div over another div using CSS
It looks sophisticated and is simple to design. Overlays can create using two simple CSS properties: z-index. position.
Read more >
Create and Manage Overlays - Sailthru Documentation
When you click New Overlay, the Choose a basic template screen opens: Click an image to select either bar or modal for the...
Read more >
How To Create a Full screen Overlay Navigation - W3Schools
Example ; /* Height & width depends on how you want to reveal the overlay (see JS below) */ height · 100% ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found