向360图像查看器添加工具提示/热点

Adding tooltips/hotspots to 360 image viewer

本文关键字:添加 工具提示 热点 图像      更新时间:2023-09-26

我的站点中使用了一个图像旋转器,但现在我需要能够将热点添加到特定角度。这是我使用的插件
http://blog.stableflow.com/jquery-plugins/360-degrees-product-view/#comments
以前有人用过这个吗?可以在推特上添加热点吗?

我查看了插件代码,它不支持使用图像映射,所以我提取了您需要的基本代码,并在第三个图像上添加了一个大的黄点,您可以将其悬停在上面-这是一个演示。

HTML

<div id="product" style="width: 640px; height: 480px; overflow: hidden;">
    ...
    <img src="03.jpg" usemap="#img03" />
    <map name="img03" width="640" height="480">
        <area shape="circle" coords="366,154,65" href="#" title="Yellow Dot!" />
    </map>
    ...
</div>

CSS

.notseen {
    position: absolute;
    left: 0;
    top: 0;
    visibility: hidden;
}

编写脚本

// original: http://blog.stableflow.com/jquery-plugins/360-degrees-product-view/
// No need to include the plugin, this is a simplified version of it
jQuery(document).ready(function ($) {
    var $product = $('#product'),
        $imgs = $product.find('img'),
        imageTotal = $imgs.length - 1,
        clicked = false,
        widthStep = 4,
        currPos,
        currImg = 0,
        lastImg = 0;
    $imgs.bind('mousedown', function (e) {
        e.preventDefault(); // prevent dragging images
    })
        .filter(':gt(0)').addClass('notseen');
    $product.bind('mousedown touchstart', function (e) {
        if (e.type == "touchstart") {
            currPos = window.event.touches[0].pageX;
        } else {
            currPos = e.pageX;
        }
        clicked = true;
        return false;
    });
    $(document)
        .bind('mouseup touchend', function () {
        clicked = false;
    })
        .bind('mousemove touchmove', function (e) {
        if (clicked) {
            var pageX;
            if (e.type == "touchmove") {
                pageX = window.event.targetTouches[0].pageX;
            } else {
                pageX = e.pageX;
            }
            widthStep = 4;
            if (Math.abs(currPos - pageX) >= widthStep) {
                if (currPos - pageX >= widthStep) {
                    currImg++;
                    if (currImg > imageTotal) {
                        currImg = 1;
                    }
                } else {
                    currImg--;
                    if (currImg < 1) {
                        currImg = imageTotal;
                    }
                }
                currPos = pageX;
                $imgs.eq(lastImg).addClass('notseen');
                $imgs.eq(currImg).removeClass('notseen');
                lastImg = currImg;
                // $obj.html('<img src="' + aImages[options.currImg] + '" />');
            }
        }
    });
});