-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathjquery.scrollUp.min.js
More file actions
7 lines (7 loc) · 2.07 KB
/
jquery.scrollUp.min.js
File metadata and controls
7 lines (7 loc) · 2.07 KB
1
2
3
4
5
6
7
/*!
* scrollup v2.4.1
* Url: http://markgoodyear.com/labs/scrollup/
* Copyright (c) Mark Goodyear — @markgdyr — http://markgoodyear.com
* License: MIT
*/
!function(l,o,e){"use strict";l.fn.scrollUp=function(o){l.data(e.body,"scrollUp")||(l.data(e.body,"scrollUp",!0),l.fn.scrollUp.init(o))},l.fn.scrollUp.init=function(r){var s,t,c,n,i,a,p,d=l.fn.scrollUp.settings=l.extend({},l.fn.scrollUp.defaults,r),f=!1;switch(p=d.scrollTrigger?l(d.scrollTrigger):l("<a/>",{id:d.scrollName,href:"#top"}),d.scrollTitle&&p.attr("title",d.scrollTitle),p.appendTo("body"),d.scrollImg||d.scrollTrigger||p.html(d.scrollText),p.css({display:"none",position:"fixed",zIndex:d.zIndex}),d.activeOverlay&&l("<div/>",{id:d.scrollName+"-active"}).css({position:"absolute",top:d.scrollDistance+"px",width:"100%",borderTop:"1px dotted"+d.activeOverlay,zIndex:d.zIndex}).appendTo("body"),d.animation){case"fade":s="fadeIn",t="fadeOut",c=d.animationSpeed;break;case"slide":s="slideDown",t="slideUp",c=d.animationSpeed;break;default:s="show",t="hide",c=0}n="top"===d.scrollFrom?d.scrollDistance:l(e).height()-l(o).height()-d.scrollDistance,i=l(o).scroll(function(){l(o).scrollTop()>n?f||(p[s](c),f=!0):f&&(p[t](c),f=!1,l(o).trigger("ontop.scrollup"))}),d.scrollTarget?"number"==typeof d.scrollTarget?a=d.scrollTarget:"string"==typeof d.scrollTarget&&(a=Math.floor(l(d.scrollTarget).offset().top)):a=0,p.click(function(o){o.preventDefault(),l("html, body").animate({scrollTop:a},d.scrollSpeed,d.easingType)})},l.fn.scrollUp.defaults={scrollName:"scrollUp",scrollDistance:300,scrollFrom:"top",scrollSpeed:300,easingType:"linear",animation:"fade",animationSpeed:200,scrollTrigger:!1,scrollTarget:!1,scrollText:"Scroll to top",scrollTitle:!1,scrollImg:!1,activeOverlay:!1,zIndex:2147483647},l.fn.scrollUp.destroy=function(r){l.removeData(e.body,"scrollUp"),l("#"+l.fn.scrollUp.settings.scrollName).remove(),l("#"+l.fn.scrollUp.settings.scrollName+"-active").remove(),l.fn.jquery.split(".")[1]>=7?(l(o).off("scroll",r),l(o).off(".scrollup")):(l(o).unbind("scroll",r),l(o).unbind("ontop.scrollup"))},l.scrollUp=l.fn.scrollUp}(jQuery,window,document);