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

images in hotspots automatically link to themselves #1231

Open
codingisverytaxing opened this issue Aug 25, 2024 · 2 comments
Open

images in hotspots automatically link to themselves #1231

codingisverytaxing opened this issue Aug 25, 2024 · 2 comments
Labels

Comments

@codingisverytaxing
Copy link

codingisverytaxing commented Aug 25, 2024

Hi, everything's running awesomely so far and this viewer is incredible. I have set up some standard hotspots with images included like this:

        {
            "pitch": -15.21401074363825,
            "yaw": -49.12633812097041,			
            "type": "info",
            "cssClass": "image",
            "text": "xyz",           
            "image": './assets/image.jpg',                   
        },

I don't even think this is officially supported but after messing with the custom hotspot class it works just fine. The only problem is, that tapping/ clickingthe image takes you to a new tab of that image since it references itself as a link by default. I haven't found a simple way to prevent this behaviour ansd was wondering if someone new the way to do this?

Thanks in advance for any time spent,
Michael

@mpetroff
Copy link
Owner

mpetroff commented Sep 7, 2024

I don't even think this is officially supported

It isn't.

I haven't found a simple way to prevent this behaviour

If you use the current Git master branch, adding "URL": "#" to the hot spot configuration should work.

Otherwise, you can use a custom createTooltipFunc with the hot spot to create the tooltip with the image. Something like this:

function createImageTooltip(div, imageURL) {
    var span = document.createElement('span');
    span.style.maxWidth = 'initial';
    
    var image = document.createElement('img');
    image.src = imageURL;
    image.style.width = '200px';
    image.style.paddingTop = '5px';
    span.appendChild(image);

    div.classList.add('pnlm-tooltip');
    div.appendChild(span);
    span.style.width = span.scrollWidth - 20 + 'px';
    span.style.marginLeft = -(span.scrollWidth - div.offsetWidth) / 2 + 'px';
    span.style.marginTop = -span.scrollHeight - 12 + 'px';
}

where you'd have a hot spot configuration something like this:

{
    "pitch": -0.9,
    "yaw": 144.4,
    "type": "info",
    "createTooltipFunc": createImageTooltip,
    "createTooltipArgs": "/path/to/image.jpg"
}

@codingisverytaxing
Copy link
Author

"URL": "#" has already done the trick, I'll be lloking into your custom tooltip suggestion suggestion anyway because the more time I spent fiddling with pannellum, the more ideas I have. I'm using Pannellum in my capacity as an inner city elemantary school teacher and bringing scnes to the classroom the children otherwise wouldn't be able to see is amazing.
Thanks again and tea sent your way!

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

No branches or pull requests

2 participants