1(function ($) { 2 3 var DEBUG = false, is_pocess = false; 4 5 var is_mobile = false; 6 try { 7 document.createEvent('TouchEvent'); 8 is_mobile = true; 9 } 10 catch (e) { 11 } 12 13 function easeInOutQuad(t, b, c, d) { 14 t /= d / 2; 15 if (t < 1) return c / 2 * t * t + b; 16 t--; 17 return -c / 2 * (t * (t - 2) - 1) + b; 18 } 19 20 function scrollTo(to, duration) { 21 if (is_pocess) 22 return false; 23 24 is_pocess = true; 25 var start = window.pageYOffset, 26 change = to - start, 27 currentTime = 0, 28 increment = 25; 29 30 if (is_mobile) 31 increment = increment * 3; 32 33 var animateScroll = function () { 34 currentTime += increment; 35 window.scrollTo(window.pageXOffset, easeInOutQuad(currentTime, start, change, duration)); 36 if (currentTime < duration) 37 setTimeout(animateScroll, increment); 38 }; 39 animateScroll(); 40 setTimeout(function () { 41 window.scrollTo(window.pageXOffset, to); 42 is_pocess = false; 43 }, duration + increment); 44 } 45 46 var defaults = { 47 duration: 500 48 }; 49 50 $.smoothScroll = function (to, params) { 51 52 var options = $.extend({}, defaults, params || {}); 53 54 if (DEBUG) { 55 // console.group('jquery-smooth-scroll init'); 56 console.log('to: ' + to); 57 console.log('duration: ' + options['duration']); 58 console.log('is_mobile: ' + is_mobile); 59 // console.groupEnd('jquery-smooth-scroll init'); 60 } 61 62 if (options['duration'] === 0) 63 window.scrollTo(window.pageXOffset, to); 64 else 65 scrollTo(to, options['duration']); 66 67 }; 68 69})(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.