轻量级jQuery图像注释插件 坚持

  • 源码大小:183.17KB
  • 所需积分:1积分
  • 源码编号:19JP-3134
  • 浏览次数:578次
  • 最后更新:2023年05月09日
  • 所属栏目:其他
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

粘附是一个轻量级、易于使用的jQuery插件,使您能够在图像上嵌入注释、注释、广告或其他内容。将鼠标悬停在标记上,可以在类似工具提示的弹出框中查看详细信息。

参见:

  • 用于向图像添加注释和标记的jQuery插件-imgNotes
  • jQuery插件在图像上添加文本注释-文本覆盖
  • JavaScript中的7个最佳图像注释工具

如何使用它:

1.在页面中包含jQuery粘附插件和其他资源。

  1. <script src="/path/to/cdn/jquery.min.js"></script>
  2. <script src="/path/to/jquery.adhere.min.js"></script>

2.在容器元素中插入图像,并使用ulli具有的元素数据坐标属性

  1. <section class="adhere" id="example">
  2. <figure>
  3. <img src="1.png" />
  4. </figure>
  5. <ul>
  6. <li data-coords="ah-239-29">School Seal / Logo</li>
  7. <li data-coords="ah-100-11">Survey User Comments</li>
  8. ...
  9. <li data-coords="ah-396-357">Link to Reports</li>
  10. </ul>
  11. </section>

3.在javascript中初始化并设置插件。

  1. $(".adhere").adhere({
  2. captionContainer:'ul',
  3. collapseList:true,
  4. marker:{xAlign: 'center', yAlign:'center', html:''},
  5. caption:{className:'caption', xAlign:'center', yAlign:'top'}
  6. });

4.在CSS中设置注释的样式。

  1. .img-marker {
  2. width: 11px;
  3. height: 11px;
  4. background: url('marker.png') left top no-repeat;
  5. }
  6.  
  7. .img-marker:hover { cursor: pointer; }
  8.  
  9. .caption {
  10. padding: 8px 5px;
  11. width: 130px;
  12. font-size: 12px;
  13. line-height: 17px;
  14. color: #fff;
  15. background-color: #d11919;
  16. border-radius: 3px;
  17. text-align: center;
  18. }

5.可用的插件选项。

  1. $(".adhere").adhere({
  2. captionContainer:'dl',
  3. collapseList:true,
  4. smart:false, // false, smart-inner, smart-outer
  5. marker:{className:'',xAlign:'center',yAlign:'center',html:''},
  6. caption:{className:'',xAlign:'center',yAlign:'center',xDistance:5,yDistance:5},
  7. action:{cEvent:'mouseover',cName:''}
  8. });

更新日志:

2023-03-18

  • 对缓存图像、触摸和弃用进行最少更新。

预览截图