1/** 2 * Material-scrollTop 3 * 4 * Author: Bartholomej 5 * Website: https://github.com/bartholomej/material-scrollTop 6 * Docs: https://github.com/bartholomej/material-scrollTop 7 * Repo: https://github.com/bartholomej/material-scrollTop 8 * Issues: https://github.com/bartholomej/material-scrollTop/issues 9 */ 10(function($) { 11 function mScrollTop(element, settings) { 12 13 var _ = this, 14 breakpoint; 15 var scrollTo = 0; 16 17 _.btnClass = '.material-scrolltop'; 18 _.revealClass = 'reveal'; 19 _.btnElement = $(_.btnClass); 20 21 _.initial = { 22 revealElement: 'body', 23 revealPosition: 'top', 24 padding: 0, 25 duration: 600, 26 easing: 'swing', 27 onScrollEnd: false 28 } 29 30 _.options = $.extend({}, _.initial, settings); 31 32 _.revealElement = $(_.options.revealElement); 33 breakpoint = _.options.revealPosition !== 'bottom' ? _.revealElement.offset().top : _.revealElement.offset().top + _.revealElement.height(); 34 scrollTo = element.offsetTop + _.options.padding; 35 36 $(document).scroll(function() { 37 if (breakpoint < $(document).scrollTop()) { 38 _.btnElement.addClass(_.revealClass); 39 } else { 40 _.btnElement.removeClass(_.revealClass); 41 } 42 }); 43 44 _.btnElement.click(function() { 45 var trigger = true; 46 $('html, body').animate({ 47 scrollTop: scrollTo 48 }, _.options.duration, _.options.easing, function() { 49 if (trigger) { // Fix callback triggering twice on chromium 50 trigger = false; 51 var callback = _.options.onScrollEnd; 52 if (typeof callback === "function") { 53 callback(); 54 } 55 } 56 }); 57 return false; 58 }); 59 } 60 61 $.fn.materialScrollTop = function() { 62 var _ = this, 63 opt = arguments[0], 64 l = _.length, 65 i = 0; 66 if (typeof opt == 'object' || typeof opt == 'undefined') { 67 _[i].materialScrollTop = new mScrollTop(_[i], opt); 68 } 69 return _; 70 }; 71}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.