项目作者: scrollpress

项目描述 :
JQuery plugin to make scroll top move with smooth animation.
高级语言: JavaScript
项目地址: git://github.com/scrollpress/scrollpress.git
创建时间: 2016-11-15T12:02:28Z
项目社区:https://github.com/scrollpress/scrollpress

开源协议:MIT License

下载


ScrollPress

JQuery plugin to make a smooth animation on scroll top.

V 1.3

Features

  • Animate scroll top
  • Animate DOM elements scroll top
  • JQuery UI easing functions
  • Back to top button
  • Fade in button with animation
  • Animation when click on button
  • Animate self link ( href + ID )
  • Scroll between elements with custom ease and duration

Setup

  1. $(window).scrollPress({options});

Options in act

  1. $(window).scrollPress({
  2. scrollPress: true,
  3. // Global animation duration
  4. duration: 1000,
  5. // Global animation timing function
  6. easing: 'easeInOutCubic',
  7. btn_state: null,
  8. // btn arrow icon
  9. btn_icon: "<i class='fa fa-angle-up'></i>",
  10. /**
  11. * type {Jquery selector}
  12. * example: $('.footer-element-scrollToTop')
  13. */
  14. btn_container: null,
  15. // type {Number}
  16. btn_threshold: $window.innerHeight()/3,
  17. // disable incase of styling with external stylesheet
  18. btn_inlineStyle: true,
  19. btn_style: {
  20. zIndex: '999',
  21. width: '40px',
  22. height: '40px',
  23. position: 'fixed',
  24. right: '20px',
  25. bottom: '20px',
  26. left: 'auto',
  27. top: 'auto',
  28. backgroundColor: 'white',
  29. borderRadius: '14%',
  30. transition: 'all 1s ease',
  31. animationDelay: ''
  32. },
  33. btn_fadeAnimation: {
  34. slide: true,
  35. scale: true,
  36. bounce: false,
  37. rotate: false,
  38. },
  39. // type {String}
  40. btn_fadeInClass: null,
  41. // type {Boolean}
  42. btn_clickAnimation_bounce: false,
  43. btn_clickAnimation_bubble: {
  44. state: true,
  45. outerHTML: '<div class="click-bubble-container"><div class="click-bubble"></div></div><!--/.click-bubble-->',
  46. inlineStyle: true,
  47. zIndex: '999',
  48. width: '100%',
  49. height: '100%',
  50. backgroundColor: '#96d0ff',
  51. borderRadius: null,
  52. },
  53. btn_clickAnimation_spreadBorder: {
  54. state: true,
  55. outerHTML: '<div class="spread-border"></div>\<!--/.spread-border-->',
  56. inlineStyle: true,
  57. zIndex: '997',
  58. width: '100%',
  59. height: '100%',
  60. borderWidth: '4px',
  61. borderStyle: 'solid',
  62. borderColor: '#e1e1e1',
  63. borderRadius: null
  64. },
  65. //type {String}
  66. btn_clickClass: null,
  67. /*
  68. * scroll to target offset when click on selector
  69. */
  70. scrollOnClick: {
  71. // type {JQuery selector}
  72. clickOn: null,
  73. /**
  74. * unique selector(preferred id)
  75. * type {JQuery selector}
  76. */
  77. scrollTo: null,
  78. duration: 1400,
  79. easing: null,
  80. autoDetect: true
  81. },
  82. scrollOnClick_multi: {
  83. 0: {
  84. clickOn: null,
  85. scrollTo: null,
  86. duration: null,
  87. easing: null
  88. },
  89. 1: {
  90. clickOn: null,
  91. scrollTo: null,
  92. duration: null,
  93. easing: null
  94. }
  95. }
  96. });

Class to style scroll to top button

  1. .scroll-btn .sb-layer { }
  2. /* Hover style */
  3. .scroll-btn:hover .sb-layer { }

Demo

https://scrollpress.github.io/scrollpress/demo-index.html

options

Options Type Default value Description
scrollPress Boolean true To animate scrollTop when press on any key that makes changes on scrollTop (pg up/space/…)
duration Number 1000 Duration of scrollTop animation
easing String easeInOutCubic Easing function of scrollTop animation
btn_state Boolean true Scroll to top button
btn_icon String \\ Scroll to top arrow
btn_container JQuery Selector null Scroll to top button container, to make it relative to element instead of screen. example: to put button at footer.
btn_threshold Number $window.innerHeight()/3 To show scroll to top button when scrollTop passes it.
btn_inlineStyle Boolean true Disable incase of styling with external stylesheet
btn_style Object style properties Scroll to top button style
btn_fadeAnimation Object slide/ scale Button animation when scroll top passes threshold
fadeInClass String btn_fadeAnimation classes Class added to button when scroll top passes threshold
btn_clickAnimation_bounce Boolean false Add bounce animtion when click on button
btn_clickAnimation_bubble Object Add Bubble animtion when click on button
btn_clickAnimation_spreadBorder Object Add spread border animtion when click on button
btn_clickClass String btn_clickAnimation classes Add class when click on button
scrollOnClick Object scroll to target when click on element
     autoDetect Boolean true To animate scrollTop when click on anchor that hold element id in it’s href
     clickOn JQuery selector Null To move scollTop to target when click on it
     scrollTo JQuery selector Null clickOn Target
     duration Number 1400 ScrollTop animation duration
     easing String easing ScrollTop animation timing function
scrollOnClick_multi Object Like scrollOnClick but with putting options in another Object (label). Example: scrollOnClick_multi: { home: { clickOn: … },
about: { … } }

More info

http://www.jquery-az.com/4-examples-of-scroll-top-with-animation-by-jquery-plug-in-scrollpress