全功能响应式灯箱插件 VenoBox

  • 源码大小:79.57KB
  • 所需积分:1积分
  • 源码编号:19JP-3676
  • 浏览次数:1035次
  • 最后更新:2023年07月10日
  • 所属栏目:幻灯片
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

VenoBox是一个响应迅速、移动友好的JavaScript灯箱插件,用于覆盖当前页面上的任何html元素(如图像、iframe、视频等)。

特征:

  • 支持图像和图像灯箱库(可以使用键盘箭头进行导航)。
  • 支持Ajax和内联内容。
  • 支持Youtube、Vimeo、HTML5视频。
  • 支持Iframes和谷歌地图。
  • 可访问且支持触摸。
  • 如果重叠元素的高度高于窗口,则提供滚动条。
  • 分享和下载按钮:Facebook、Twitter、LinkedIn、Pinterest。
  • 可与jQuery和Vanilla JavaScript配合使用。

基本用法:

1.包括所需内容静脉箱.cssvenobox.js在您的网页上。

  1. <!-- Required For jQuery Version Only -->
  2. <script src="/path/to/cdn/jquery.min.js"></script>
  3. <!-- venobox Plugin files -->
  4. <link href="/path/to/venobox/venobox.css" rel="stylesheet" />
  5. <script src="/path/to/venobox/venobox.js"></script>

2.初始化插件,我们就可以开始了。

  1. // jQuery Version
  2. $('.venobox').venobox({
  3. // settings here
  4. });
  5.  
  6. // Vanilla JS Version
  7. new VenoBox();

3.从一组图像中创建一个图库灯箱。请注意,图像与数据胆属性否则,当您单击缩略图时,它只显示一个图像灯箱。

  1. <a class="venobox"
  2. data-gall="myGallery"
  3. title="Image 1"
  4. href="1.jpg">
  5. <img src="thumb.jpg" />
  6. </a>
  7. <a class="venobox"
  8. data-gall="myGallery"
  9. title="Image 2"
  10. href="2.jpg">
  11. <img src="thumb.jpg" />
  12. </a>
  13. <a class="venobox"
  14. data-gall="myGallery"
  15. title="Image 3"
  16. href="3.jpg">
  17. <img src="thumb.jpg" />
  18. </a>

4.在灯箱中显示内联内容。

  1. <!-- Trigger element -->
  2. <a class="venobox"
  3. data-gall="myGallery"
  4. data-title="inline content"
  5. data-vbtype="inline"
  6. href="#inline-content">
  7. Inline Content
  8. </a>
  9.  
  10. <!-- Inline Content -->
  11. <div id="inline-content" style="display:none;">
  12. Inline Content Here
  13. </div>

5.在灯箱中显示iframe内容。

  1. <a class="venobox"
  2. data-gall="iframe"
  3. data-vbtype="iframe"
  4. title="iFrame example"
  5. href="https://example.com/">
  6. iFrame
  7. </a>

6.在灯箱中显示AJAX内容。

  1. <a class="venobox"
  2. data-gall="iframe"
  3. data-vbtype="ajax"
  4. data-ratio="16x9"
  5. href="ajax.php">
  6. Ajax
  7. </a>

7.将Youtube、Vimeo或HTML5视频嵌入灯箱。

  1. <a class="venobox"
  2. data-gall="gall-video"
  3. data-autoplay="true"
  4. data-vbtype="video"
  5. data-ratio="4x3"
  6. href="http://vimeo.com/75976293">
  7. Vimeo
  8. </a>
  9.  
  10. <a class="venobox"
  11. data-gall="gall-video"
  12. data-autoplay="true"
  13. data-vbtype="video"
  14. href="https://youtu.be/bS5P_LAqiVg">
  15. YouTube
  16. </a>

8.您也可以在页面加载时打开灯箱中的默认项目,方法是添加#第一链接至所需的触发元件。

  1. <a id="firstlink"
  2. class="venobox"
  3. data-gall="myGallery"
  4. title="Image 1"
  5. href="1.jpg">
  6. <img src="thumb.jpg" />
  7. </a>

9.设置灯箱的最大宽度。

  1. <a class="venobox"
  2. data-maxwidth="600px"
  3. title="My Description"
  4. href="image-big.jpg">
  5. Open image
  6. </a>

10.自定义覆盖的背景颜色。

  1. <a class="venobox"
  2. data-overlay="rgba(95,164,255,0.8)"
  3. title="My Description"
  4. href="image-big.jpg">
  5. Open image
  6. </a>

11.配置灯箱的可用选项。

  1. var venobox = new VenoBox({
  2.  
  3. // Items selector
  4. selector: "",
  5.  
  6. // color of navigation arrows
  7. // * jquery version only
  8. arrowsColor: '#B6B6B6',
  9.  
  10. // same as data-autoplay
  11. autoplay: false,
  12.  
  13. // background color
  14. bgcolor: '#fff',
  15.  
  16. // border
  17. border: '0',
  18.  
  19. // custom CSS class
  20. customClass: false,
  21.  
  22. // infinite loop
  23. // * vanilla JS version only
  24. infinigall: false,
  25.  
  26. // max width
  27. // * vanilla JS version only
  28. maxWidth: "1200px",
  29.  
  30. // navigation options
  31. // * vanilla JS version only
  32. navigation: true,
  33. navKeyboard: true,
  34. navTouch: true,
  35. navSpeed: 300,
  36.  
  37. // show navigation number and total items in current gallery
  38. // * vanilla JS version only
  39. numeration: false,
  40.  
  41. // background color of close button
  42. closeBackground: '#161617',
  43.  
  44. // colr of close button
  45. closeColor: "#d2d2d2",
  46.  
  47. // frame width/height
  48. // * jQuery version only
  49. framewidth: '',
  50. frameheight: '',
  51.  
  52. // show items as a gallery
  53. // * jQuery version only
  54. gallItems: false,
  55.  
  56. // custom controls
  57. // * jQuery version only
  58. htmlClose: '&times;',
  59. htmlNext: '<span>Next</span>',
  60. htmlPrev: '<span>Prev</span>',
  61.  
  62. // background color of counter
  63. // * jQuery version only
  64. numerationBackground: '#161617',
  65.  
  66. // counter color
  67. // * jQuery version only
  68. numerationColor: '#d2d2d2',
  69.  
  70. // 'top' || 'bottom'
  71. // * jQuery version only
  72. numerationPosition: 'top',
  73.  
  74. // close the lightbox by clicking the background overlay
  75. overlayClose: true,
  76.  
  77. // color of the background overlay
  78. overlayColor: 'rgba(23,23,23,0.85)',
  79.  
  80. // show automatic popup on page load
  81. // * vanilla JS version only
  82. popup: "false",
  83.  
  84. // '1x1' | '4x3' | '16x9' | '21x9' | 'full'
  85. // * vanilla JS version only
  86. ratio: "16x9",
  87.  
  88. // show sharing buttons for images and videos
  89. // * vanilla JS version only
  90. share: false,
  91.  
  92. // 'block' | 'pill' | 'transparent' | 'bar'
  93. // * vanilla JS version only
  94. shareStyle: 'bar',
  95.  
  96. // jQuery version: 'rotating-plane' | 'double-bounce' | 'wave' | 'wandering-cubes' | 'spinner-pulse' | 'chasing-dots' | 'three-bounce' | 'circle' | 'cube-grid' | 'fading-circle' | 'folding-cube'
  97. // Vanilla JS version: 'plane' | 'chase' | 'bounce' | 'wave' | 'pulse' | 'flow' | 'swing' | 'circle' | 'circle-fade' | 'grid' | 'fold | 'wander'
  98. spinner: 'double-bounce',
  99.  
  100. // spinner color
  101. spinColor: '#d2d2d2',
  102.  
  103. // same as data-title
  104. titleattr: 'title',
  105.  
  106. // 'top' || 'bottom'
  107. titlePosition: 'top'
  108.  
  109. // title background color
  110. // * jQuery version only
  111. titleBackground: '#161617',
  112.  
  113. // title color
  114. // * jQuery version only
  115. titleColor: '#d2d2d2',
  116.  
  117. // background color of title and share buttons
  118. // * vanilla JS version only
  119. toolsBackground: "#1C1C1C",
  120.  
  121. // color of Title, Share buttons and gallery navigation
  122. // * vanilla JS version only
  123. toolsColor: '#d2d2d2',
  124.  
  125. });

12.回调函数。

  1. // Vanilla JS Version
  2. var venobox = new VenoBox({
  3. // Return the selected object - set return false to prevent opening
  4. onPreOpen: function(){ return true; },
  5. // Return: current_item, gallIndex, thenext, theprev
  6. onPostOpen: function(){},
  7. // Return: current_item, gallIndex, thenext, theprev - set return false to prevent closing
  8. onPreClose: function(){ return true; },
  9. // Return: current_item, gallIndex, thenext, theprev
  10. onNavComplete: function(){},
  11. // Return: newcontent
  12. onContentLoaded: function(){},
  13. // Return: plugin obj
  14. onInit: function(){},
  15. });
  16.  
  17. // jQuery Version
  18. $('.venobox').venobox({
  19. cb_pre_open: function(){ return true; },
  20. cb_post_open: function(){},
  21. cb_pre_close: function(){ return true; },
  22. cb_post_close: function(){},
  23. cb_post_resize: function(){},
  24. cb_after_nav: function(){},
  25. cb_content_loaded: function(){},
  26. cb_init: function(){}
  27. });

13.API方法。

  1. var venobox = new VenoBox();
  2.  
  3. // open a specific item
  4. venobox.open('#my-link');
  5.  
  6. // close the lightbox
  7. venobox.close();
  8.  
  9. // goto the next item
  10. venobox.next();
  11.  
  12. // back to the prev item
  13. venobox.prev();
  14.  
  15. // destroy the instance
  16. venobox.destroy();

更新日志:

2022-03-08

  • 更新:youtube noookie支持

2.0.4版(2021-12-17)

  • 新选项:customClass
  • 新属性:data-customclass(覆盖全局选项customclass)
  • 新属性:数据边界(替代全局选项边界)
  • 新增:选项比例:iFrame和视频内容的100%视口高度为“满”

2.0.3版(2021-12-13)

  • 新增:快速图库导航

2.0.0版(2021-12-08)

  • 用Vanilla JavaScript重写。

v1.9.4 (2021-11-17)

  • JS更新

预览截图