1/** 2 * PLUGIN NAME: easeScroll - https://github.com/ivmello/easeScroll 3 * AUTHOR: ivmello - https://github.com/ivmello 4 * VERSION: 1.0.0 5 * */ 6 7(function ($) { 8 $.fn.easeScroll = function (options) { 9 !function () { 10 function e() { 11 var e = !1; 12 e && c("keydown", r), v.keyboardSupport && !e && u("keydown", r) 13 } 14 15 function t() { 16 if (document.body) { 17 var t = document.body, 18 o = document.documentElement, 19 n = window.innerHeight, 20 r = t.scrollHeight; 21 if (S = document.compatMode.indexOf("CSS") >= 0 ? o : t, w = t, e(), x = !0, top != self) y = !0; 22 else if (r > n && (t.offsetHeight <= n || o.offsetHeight <= n)) { 23 var a = !1, 24 i = function () { 25 a || o.scrollHeight == document.height || (a = !0, setTimeout(function () { 26 o.style.height = document.height + "px", a = !1 27 }, 100)) 28 }; 29 if (o.style.height = "auto", setTimeout(i, 10), S.offsetHeight <= n) { 30 var l = document.createElement("div"); 31 l.style.clear = "both", t.appendChild(l) 32 } 33 } 34 v.fixedBackground || b || (t.style.backgroundAttachment = "scroll", o.style.backgroundAttachment = "scroll") 35 } 36 } 37 38 function o(e, t, o, n) { 39 if (n || (n = 1e3), d(t, o), 1 != v.accelerationMax) { 40 var r = +new Date, 41 a = r - C; 42 if (a < v.accelerationDelta) { 43 var i = (1 + 30 / a) / 2; 44 i > 1 && (i = Math.min(i, v.accelerationMax), t *= i, o *= i) 45 } 46 C = +new Date 47 } 48 if (M.push({ 49 x: t, 50 y: o, 51 lastX: 0 > t ? .99 : -.99, 52 lastY: 0 > o ? .99 : -.99, 53 start: +new Date 54 }), !T) { 55 var l = e === document.body, 56 u = function () { 57 for (var r = +new Date, a = 0, i = 0, c = 0; c < M.length; c++) { 58 var s = M[c], 59 d = r - s.start, 60 f = d >= v.animationTime, 61 h = f ? 1 : d / v.animationTime; 62 v.pulseAlgorithm && (h = p(h)); 63 var m = s.x * h - s.lastX >> 0, 64 w = s.y * h - s.lastY >> 0;
65 a += m, i += w, s.lastX += m, s.lastY += w, f && (M.splice(c, 1), c--) 66 } 67 l ? window.scrollBy(a, i) : (a && (e.scrollLeft += a), i && (e.scrollTop += i)), t || o || (M = []), M.length ? E(u, e, n / v.frameRate + 1) : T = !1 68 }; 69 E(u, e, 0), T = !0 70 } 71 } 72 73 function n(e) { 74 x || t(); 75 var n = e.target, 76 r = l(n); 77 if (!r || e.defaultPrevented || s(w, "embed") || s(n, "embed") && /\.pdf/i.test(n.src)) return !0; 78 var a = e.wheelDeltaX || 0, 79 i = e.wheelDeltaY || 0; 80 return a || i || (i = e.wheelDelta || 0), !v.touchpadSupport && f(i) ? !0 : (Math.abs(a) > 1.2 && (a *= v.stepSize / 120), Math.abs(i) > 1.2 && (i *= v.stepSize / 120), o(r, -a, -i), void e.preventDefault()) 81 } 82 83 function r(e) { 84 var t = e.target, 85 n = e.ctrlKey || e.altKey || e.metaKey || e.shiftKey && e.keyCode !== H.spacebar; 86 if (/input|textarea|select|embed/i.test(t.nodeName) || t.isContentEditable || e.defaultPrevented || n) return !0; 87 if (s(t, "button") && e.keyCode === H.spacebar) return !0; 88 var r, a = 0, 89 i = 0, 90 u = l(w), 91 c = u.clientHeight; 92 switch (u == document.body && (c = window.innerHeight), e.keyCode) { 93 case H.up: 94 i = -v.arrowScroll; 95 break; 96 case H.down: 97 i = v.arrowScroll; 98 break; 99 case H.spacebar: 100 r = e.shiftKey ? 1 : -1, i = -r * c * .9; 101 break; 102 case H.pageup: 103 i = .9 * -c; 104 break; 105 case H.pagedown: 106 i = .9 * c; 107 break; 108 case H.home: 109 i = -u.scrollTop; 110 break; 111 case H.end: 112 var d = u.scrollHeight - u.scrollTop - c; 113 i = d > 0 ? d + 10 : 0; 114 break; 115 case H.left: 116 a = -v.arrowScroll; 117 break; 118 case H.right: 119 a = v.arrowScroll; 120 break; 121 default: 122 return !0 123 } 124 o(u, a, i), e.preventDefault() 125 } 126 127 function a(e) { 128 w = e.target 129 } 130 131 function i(e, t) { 132 for (var o = e.length; o--;) z[N(e[o])] = t; 133 return t 134 } 135 136 function l(e) { 137 var t = [], 138 o = S.scrollHeight; 139 do { 140 var n = z[N(e)]; 141 if (n) return i(t, n); 142 if (t.push(e), o === e.scrollHeight) { 143 if (!y || S.clientHeight + 10 < o) return i(t, document.body) 144 } else if (e.clientHeight + 10 < e.scrollHeight && (overflow = getComputedStyle(e, "").getPropertyValue("overflow-y"), "scroll" === overflow || "auto" === overflow)) return i(t, e) 145 } while (e = e.parentNode) 146 } 147 148 function u(e, t, o) { 149 window.addEventListener(e, t, o || !1) 150 } 151 152 function c(e, t, o) { 153 window.removeEventListener(e, t, o || !1) 154 } 155 156 function s(e, t) { 157 return (e.nodeName || "").toLowerCase() === t.toLowerCase() 158 } 159 160 function d(e, t) { 161 e = e > 0 ? 1 : -1, t = t > 0 ? 1 : -1, (k.x !== e || k.y !== t) && (k.x = e, k.y = t, M = [], C = 0) 162 } 163 164 function f(e) { 165 if (e) { 166 e = Math.abs(e), D.push(e), D.shift(), clearTimeout(A); 167 var t = D[0] == D[1] && D[1] == D[2], 168 o = h(D[0], 120) && h(D[1], 120) && h(D[2], 120); 169 return !(t || o) 170 } 171 } 172 173 function h(e, t) { 174 return Math.floor(e / t) == e / t 175 } 176 177 function m(e) { 178 var t, o, n; 179 return e *= v.pulseScale, 1 > e ? t = e - (1 - Math.exp(-e)) : (o = Math.exp(-1), e -= 1, n = 1 - Math.exp(-e), t = o + n * (1 - o)), t * v.pulseNormalize 180 } 181 182 function p(e) { 183 return e >= 1 ? 1 : 0 >= e ? 0 : (1 == v.pulseNormalize && (v.pulseNormalize /= m(1)), m(e)) 184 } 185 186 var settings = $.extend({ 187 // These are the defaults. 188 frameRate: 60, 189 animationTime: 1000, 190 stepSize: 120, 191 pulseAlgorithm: !0, 192 pulseScale: 8, 193 pulseNormalize: 1, 194 accelerationDelta: 20, 195 accelerationMax: 1, 196 keyboardSupport: !0, 197 arrowScroll: 50, 198 touchpadSupport: !0,
199 fixedBackground: !0 200 }, options); 201 202 var w, g = { 203 frameRate: settings.frameRate, 204 animationTime: settings.animationTime, 205 stepSize: settings.stepSize, 206 pulseAlgorithm: settings.pulseAlgorithm, 207 pulseScale: settings.pulseScale, 208 pulseNormalize: settings.pulseNormalize, 209 accelerationDelta: settings.accelerationDelta, 210 accelerationMax: settings.accelerationMax, 211 keyboardSupport: settings.keyboardSupport, 212 arrowScroll: settings.arrowScroll, 213 touchpadSupport: settings.touchpadSupport, 214 fixedBackground: settings.fixedBackground, 215 excluded: "" 216 }, 217 v = g, 218 b = !1, 219 y = !1, 220 k = { 221 x: 0, 222 y: 0 223 }, 224 x = !1, 225 S = document.documentElement, 226 D = [120, 120, 120], 227 H = { 228 left: 37, 229 up: 38, 230 right: 39, 231 down: 40, 232 spacebar: 32, 233 pageup: 33, 234 pagedown: 34, 235 end: 35, 236 home: 36 237 }, 238 v = g, 239 M = [], 240 T = !1, 241 C = +new Date, 242 z = {}; 243 setInterval(function () { 244 z = {} 245 }, 1e4); 246 var A, N = function () { 247 var e = 0; 248 return function (t) { 249 return t.uniqueID || (t.uniqueID = e++) 250 } 251 }(), 252 E = function () { 253 return window.requestAnimationFrame || window.webkitRequestAnimationFrame || function (e, t, o) { 254 window.setTimeout(e, o || 1e3 / 60) 255 } 256 }(), 257 K = /chrome|iPad/i.test(window.navigator.userAgent), 258 L = "onmousewheel" in document; 259 L && K && (u("mousedown", a), u("mousewheel", n), u("load", t)) 260 }(); 261 }; 262 263 264 // Load plugin at ready 265 $(document).ready(function(){ 266 var macOs = navigator.appVersion.indexOf("Mac")!=-1, 267 isChrome = !!window.chrome, 268 stepSize = 120; 269 270 $.browser.device = (/Android|iPad|iPhone|iPod|BlackBerry|Windows Phone|opera mini|iemobile/i.test(navigator.userAgent || navigator.vendor || window.opera)); 271 272 // Disable plugin on mobile device 273 if (!$.browser.device) { 274 275 // Change step size for Chrome MacOs 276 if (macOs && isChrome == true) { 277 stepSize = 50; 278 } 279 280 // Initialization the plugin 281 $("html").easeScroll({ 282 stepSize: stepSize, 283 arrowScroll: 100 284 }); 285 } 286 }); 287})(jQuery); 288
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.