jQuery 动画随机标记云插件 Tag Cloud.js

  • 源码大小:14.74KB
  • 所需积分:1积分
  • 源码编号:19JP-3592
  • 浏览次数:1029次
  • 最后更新:2023年06月29日
  • 所属栏目:文本
本站默认解压密码:19jp.com 或 19jp_com

简介

一个易于使用的jQuery标签云生成器,从一组链接中生成具有随机权重和随机背景/文本颜色的动画标签

将鼠标悬停在任何标记上时,所有其他标记都将变暗以高亮显示当前标记。使用纯JavaScript和CSS编写。不需要SVG、图像和画布。

创建它的目的是在没有适当分类法的网站上工作时减少类别的使用,具有可接受的随机性,避免沮丧或无聊。

参见:

  • 10最佳JavaScript标记云生成器

如何使用它:

1.下载并加载jquery.tag-cloud.jsjQuery之后的脚本。

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

2.将任意数量的标签链接插入到标签云。

  1. <div class="tag-cloud">
  2. <a href="#">Tag 1</a>
  3. <a href="#">Tag 2</a>
  4. <a href="#">Tag 3</a>
  5. ... more tags here ...
  6. </div>

3.调用函数生成一个基本的标签云。

  1. $(".tag-cloud").tagCloud({
  2. // options here
  3. });

4.覆盖默认设置以自定义标记云。

  1. $(".tag-cloud").tagCloud({
  2.  
  3. // min/max colors
  4. minColor: "#333",
  5. maxColor: "#eee",
  6.  
  7. // min/max tag size in px
  8. minSize: 40,
  9. maxSize: 150,
  10.  
  11. // min font size in px
  12. minFontSize: 12,
  13.  
  14. // CSS class for the current tag
  15. currentClass: "tag-cloud-enter",
  16. // offset in px
  17. offset: [0, 0, 0, 0],
  18.  
  19. // border-radius property
  20. radius: "50%",
  21.  
  22. // 16 = hex
  23. // or rgb
  24. // or rgba
  25. colorType: 16,
  26.  
  27. // config the animation here
  28. anim: {
  29. // or 'warp', 'one'
  30. name: "bomb",
  31. time: "500",
  32. delay: "50"
  33. },
  34.  
  35. // background color
  36. bgColor : "",
  37.  
  38. // text color
  39. color : "",
  40.  
  41. // or 'divisor'
  42. method : "area",
  43. });

5.回调函数。

  1. $(".tag-cloud").tagCloud({
  2.  
  3. // on mouseenter
  4. enter: function(opt, id, pos, posArr, posRc, W, H, opts) {},
  5.  
  6. // on mouseleave
  7. leave: function(opt, id, pos, posArr, rc, W, H, opts) {},
  8.  
  9. // on start
  10. start: function(opts) {},
  11.  
  12. // before handling tags
  13. printing: function(opts) {},
  14.  
  15. // after handling tags
  16. printed: function(opts) {},
  17.  
  18. // after events have been attached to the tags
  19. addEvented: function(opts) {},
  20.  
  21. // after the animation has finished
  22. animed: function(opts) {},
  23.  
  24. // after the tag cloud has rendered
  25. complate: function(opts) {},
  26.  
  27. });

预览截图