mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.
https://pannellum.org/
MIT License
4.23k stars 721 forks source link

Dragging hotspot #1182

Open hendrialqori opened 11 months ago

hendrialqori commented 11 months ago

Hello @mpetroff 

Is there an example of how to make hotspot draggable? I have read doc/json-config-parameters.md but it does not work for me.

Thank you in advance.

mpetroff commented 11 months ago

Here's an example:

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hot spots</title>
    <link rel="stylesheet" href="../src/css/pannellum.css"/>
    <script type="text/javascript" src="../src/js/pannellum.js"></script>
    <script type="text/javascript" src="../src/js/libpannellum.js"></script>
    <style>
    #panorama {
        width: 600px;
        height: 400px;
    }
    </style>
</head>
<body>

<div id="panorama"></div>
<script>
function dragHandler(event, args) {
    console.log(event, args);
}

pannellum.viewer('panorama', {
    "type": "equirectangular",
    "panorama": "examplepano.jpg",
    "hotSpots": [
        {
            "pitch": 14.1,
            "yaw": 1.5,
            "type": "info",
            "text": "Example",
            "draggable": true,
            "dragHandlerFunc": dragHandler,
            "dragHandlerArgs": "example arg"
        },
    ]
});
</script>

</body>
</html>

Note that this was added after v2.5.6 was released, so you need to use the Git master branch.