专业jQuery内容滑块插件 Slider Pro

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

简介

Slider Pro是一个专业的JavaScript插件,允许您在响应和触摸兼容的滑块中显示一组混合内容。

主要功能:

  • 完全响应自定义JS断点。
  • 触摸滑动、键盘和缩略图导航。
  • 全屏和自动高度支持。
  • CSS3供电的转换。
  • 像旋转木马一样无限循环。
  • 镜像延迟加载。
  • 视网膜图像支持。
  • Galley灯箱已启用。
  • 自动视频处理。
  • 深度链接。
  • 支持混合内容,而不仅仅是图像。
  • 兼容jQuery和Vanilla JavaScript。

基本用法:

1.在文档中加载jQuery Slider Pro插件的样式表和脚本。

  1. <!-- jQuery Version -->
  2. <link rel="stylesheet" href="./dist/css/slider-pro.min.css" />
  3. <script src="http://code.jquery.com/jquery.min.js"></script>
  4. <script src="/dist/js/jquery.sliderPro.min.js"></script>
  5.  
  6. <!-- Vanilla JavaScript -->
  7. <link rel="stylesheet" href="./build/slider-pro.css" />
  8. <script src="./build/slider-pro.js"></script>

2.基本的标记结构。

  1. <div id="demo" class="slider-pro">
  2. <div class="sp-slides">
  3. <div class="sp-slide"> <img class="sp-image" src="1.jpg"> </div>
  4. <div class="sp-slide"> <img class="sp-image" src="2.jpg"> </div>
  5. <div class="sp-slide">
  6. <img class="sp-image" src="3.jpg">
  7. <h3 class="sp-layer">Text layer</h3>
  8. <p class="sp-layer">Text layer</p>
  9. </div>
  10. </div>
  11. </div>

3.通过调用父元素上的函数来初始化滑块。

  1. // jQuery Version
  2. $('#demo').sliderPro({
  3. // options here
  4. });
  5.  
  6. // Vanilla JavaScript
  7. const slider = new SliderPro('#demo', {
  8. // options here
  9. });

4.自定义滑块的所有默认选项。

  1. // Width of the slide
  2. width: 500,
  3.  
  4. // Height of the slide
  5. height: 300,
  6.  
  7. // Indicates if the slider is responsive
  8. responsive: true,
  9.  
  10. // The aspect ratio of the slider (width/height)
  11. aspectRatio: -1,
  12.  
  13. // The scale mode for images (cover, contain, exact and none)
  14. imageScaleMode: 'cover',
  15.  
  16. // Indicates if the image will be centered
  17. centerImage: true,
  18.  
  19. // Indicates if the image can be scaled up more than its original size
  20. allowScaleUp: true,
  21.  
  22. // Indicates if height of the slider will be adjusted to the
  23. // height of the selected slide
  24. autoHeight: false,
  25.  
  26. // Will maintain all the slides at the same height, but will allow the width of the slides to be variable if the orientation of the slides is horizontal and vice-versa if the orientation is vertical.
  27. autoSlideSize: false,
  28.  
  29. // Indicates the initially selected slide
  30. startSlide: 0,
  31.  
  32. // Indicates if the slides will be shuffled
  33. shuffle: false,
  34.  
  35. // Indicates whether the slides will be arranged horizontally
  36. // or vertically. Can be set to 'horizontal' or 'vertical'.
  37. orientation: 'horizontal',
  38.  
  39. // Indicates if the size of the slider will be forced to 'fullWidth' or 'fullWindow'
  40. forceSize: 'none',
  41.  
  42. // Indicates if the slider will be loopable
  43. loop: true,
  44.  
  45. // The distance between slides
  46. slideDistance: 10,
  47.  
  48. // The duration of the slide animation
  49. slideAnimationDuration: 700,
  50.  
  51. // The duration of the height animation
  52. heightAnimationDuration: 700,
  53.  
  54. // Sets the size of the visible area, allowing the increase of it in order
  55. // to make more slides visible.
  56. // By default, only the selected slide will be visible.
  57. visibleSize: 'auto',
  58.  
  59. // Breakpoints for allowing the slider's options to be changed
  60. // based on the size of the window.
  61. breakpoints: null,
  62.  
  63. // Indicates whether the selected slide will be in the center of the slider, when there are more slides visible at a time.
  64. // If set to false, the selected slide will be in the left side of the slider.
  65. centerSelectedSlide: true,
  66.  
  67. // Indicates if the direction of the slider will be from right to left, instead of the default left to right.
  68. rightToLeft: false,
  69.  
  70. // Indicates if fade will be used.
  71. fade: 'false',
  72.  
  73. // Indicates if the previous slide will be faded out (in addition to the next slide being faded in).
  74. fadeOutPreviousSlide: true,
  75.  
  76. // Sets the duration of the fade effect.
  77. fadeDuration: 500,
  78.  
  79. // Indicates whether or not autoplay will be enabled.
  80. autoplay: true,
  81.  
  82. // Sets the delay/interval (in milliseconds) at which the autoplay will run.
  83. autoplayDelay: 5000,
  84.  
  85. // Indicates whether autoplay will navigate to the next slide or previous slide.
  86. // 'normal' and 'backwards'
  87. autoplayDirection: 'normal',
  88.  
  89. // Indicates if the autoplay will be paused or stopped when the slider is hovered.
  90. // 'pause', 'stop' and 'none'
  91. autoplayOnHover: 'pause',
  92.  
  93. // Indicates whether the arrow buttons will be created.
  94. arrows: false,
  95.  
  96. // Indicates whether the arrows will fade in only on hover.
  97. fadeArrows: true,
  98.  
  99. // Indicates whether the buttons will be created.
  100. buttons: true,
  101.  
  102. // Indicates whether keyboard navigation will be enabled.
  103. keyboard: true,
  104.  
  105. // Indicates whether the slider will respond to keyboard input only when the slider is in focus.
  106. keyboardOnlyOnFocus: false,
  107.  
  108. // Indicates whether the touch swipe will be enabled for slides.
  109. touchSwipe: true,
  110.  
  111. // Sets the minimum amount that the slides should move.
  112. touchSwipeThreshold: 50,
  113.  
  114. // Indicates whether or not the captions will be faded.
  115. fadeCaption: true,
  116.  
  117. // Sets the duration of the fade animation.
  118. captionFadeDuration: 500,
  119.  
  120. // Indicates whether the full-screen button is enabled.
  121. fullScreen: false,
  122.  
  123. // Indicates whether the button will fade in only on hover.
  124. fadeFullScreen: true,
  125.  
  126. // Indicates whether the slider will wait for the layers to disappear before going to a new slide.
  127. waitForLayers: false,
  128.  
  129. // Indicates whether the layers will be scaled automatically.
  130. autoScaleLayers: true,
  131.  
  132. // Sets a reference width which will be compared to the current slider width in order to determine how much the layers need to scale down.
  133. // By default, the reference width will be equal to the slide width.
  134. // However, if the slide width is set to a percentage value, then it's necessary to set a specific value for 'autoScaleReference'.
  135. autoScaleReference: -1,
  136.  
  137. // If the slider size is below this size, the small version of the images will be used.
  138. smallSize: 480,
  139.  
  140. // If the slider size is below this size, the medium version of the images will be used.
  141. mediumSize: 768,
  142.  
  143. // If the slider size is below this size, the large version of the images will be used.
  144. largeSize: 1024,
  145.  
  146. // Indicates whether the hash will be updated when a new slide is selected.
  147. updateHash: false,
  148.  
  149. // Sets the action that the video will perform when its slide container is selected.
  150. // 'playVideo' and 'none'
  151. reachVideoAction: 'none',
  152.  
  153. // Sets the action that the video will perform when another slide is selected.
  154. // 'stopVideo', 'pauseVideo', 'removeVideo' and 'none'
  155. leaveVideoAction: 'pauseVideo',
  156.  
  157. // Sets the action that the slider will perform when the video starts playing
  158. // 'stopAutoplay' and 'none'
  159. playVideoAction: 'stopAutoplay',
  160.  
  161. // Sets the action that the slider will perform when the video is paused.
  162. 'startAutoplay' and 'none'
  163. pauseVideoAction: 'none'
  164.  
  165. // Sets the action that the slider will perform when the video ends.
  166. // 'startAutoplay', 'nextSlide', 'replayVideo' and 'none'
  167. endVideoAction: 'none',
  168.  
  169. // Sets the width of the thumbnail.
  170. thumbnailWidth: 100,
  171.  
  172. // Sets the height of the thumbnail.
  173. thumbnailHeight: 80,
  174.  
  175. // 'top', 'bottom', 'right' and 'left'
  176. thumbnailsPosition: 'bottom',
  177.  
  178. // Indicates if a pointer will be displayed for the selected thumbnail
  179. thumbnailPointer: false,
  180.  
  181. // Indicates whether the thumbnail arrows will be enabled
  182. thumbnailArrows: false,
  183.  
  184. // Indicates whether the thumbnail arrows will be faded
  185. fadeThumbnailArrows: true,
  186.  
  187. // Indicates whether the touch swipe will be enabled for thumbnails
  188. thumbnailTouchSwipe: true,
  189.  
  190. // Called when the slider is initialized
  191. init: function() {},
  192.  
  193. // Called when the slider is updates
  194. update: function() {},
  195.  
  196. // Called when the slider is resized
  197. sliderResize: function() {},
  198.  
  199. // Called when a new slide is selected
  200. gotoSlide: function() {},
  201.  
  202. // Called when the navigation to the newly selected slide is complete
  203. gotoSlideComplete: function() {},
  204.  
  205. // Called when a breakpoint is reached
  206. breakpointReach: function() {},
  207.  
  208. // Called when a video starts playing
  209. videoPlay: function() {},
  210.  
  211. // Called when a video is paused
  212. videoPause: function() {},
  213.  
  214. // Called when a video ends.
  215. videoEnd: function() {},
  216.  
  217. // Called when all animated layers become visible
  218. showLayersComplete: function() {},
  219.  
  220. // Called when all animated layers become invisible
  221. hideLayersComplete: function() {},
  222.  
  223. // Called when the thumbnails are updated
  224. thumbnailsUpdate: function() {},
  225.  
  226. // Called when a new thumbnail is selected
  227. gotoThumbnail: function() {},
  228.  
  229. // Called when the thumbnail scroller has moved
  230. thumbnailsMoveComplete: function() {},

5.公开方法。

  1. // Scrolls to the slide at the specified index.
  2. gotoSlide( index )
  3.  
  4. // Scrolls to the next slide.
  5. nextSlide()
  6.  
  7. // Scrolls to the previous slide.
  8. previousSlide()
  9.  
  10. // Gets all the data of the slide at the specified index.
  11. // Returns an object that contains all the data specified for that slide.
  12. getSlideAt( index )
  13.  
  14. // Gets the index of the selected slide.
  15. getSelectedSlide()
  16.  
  17. // This is called by the plugin automatically when a property is changed.
  18. // You can call this manually in order to refresh the slider after changing its HTML markup
  19. // (i.e., adding or removing slides).
  20. update()
  21.  
  22. // This is called by the plugin automatically when the slider changes its size.
  23. // You can also call it manually if you find it necessary to have the slider resize itself.
  24. resize()
  25.  
  26. // Gets the total number of slides.
  27. getTotalSlides()
  28.  
  29. // Adds an event listener to the slider.
  30. // More details about the use of this method will be presented in the 'Callbacks' chapter.
  31. on( eventType, callback )
  32.  
  33. // Removes an event listener from the slider.
  34. off( eventType )
  35.  
  36. // Destroys a slider by removing all the visual elements and functionality added by the plugin.
  37. // Basically, it leaves the slider in the state it was before the plugin was instantiated.
  38. destroy()

6.更多的例子来了解这个很棒的滑块插件。

  • 基本示例
  • 全宽转盘
  • 底部缩略图
  • 视频示例
  • 垂直缩略图

更新日志:

v1.6.2 (2023-01-19)

  • 滑块损坏时清除计时器

v1.6.1 (2022-12-16)

  • JS和CSS已更新

v1.6.0 (2021-06-15)

  • JS和CSS已更新

v1.5.0(2018年10月24日)

  • 更新延迟加载以检查所选幻灯片是否居中

v1.3.0 (2016-07-11)

  • 使现代化

v1.2.5 (2016-07-01)

  • 添加rtl支持

v1.2.5 (2016-03-03)

  • 使现代化

v1.2.4(2015年11月13日)

  • 将“allowfullscreen”添加到youtube和vimeo视频

v1.2.3(2015年10月16日)

  • 使现代化

v1.2.1(2015年3月16日)

  • 使现代化

v1.2.0(2015年1月30日)

  • 使现代化

v1.1.0 (2014-12-12)

  • 改善视网膜支撑

v1.0.9 (2014-12-07)

  • 将字体图标替换为缩略图指针的CSS形状

v1.0.8 (2014-12-03)

  • 修复条件图像模块中不必要的图像交换

v1.0.7 (2014-12-01)

  • 重构缩略图指针的CSS

v1.0.6 (2014-11-22)

  • 修复“顶部”选项的缩略图位置

v1.0.5 (2014-11-19)

  • 修复缩略图继承

v1.0.3 (2014-11-04)

  • 修复退出全屏后不正确的边距

v1.0.2 (2014-11-03)

  • 固定视网膜模块中dppx值从192到2

预览截图