PageSourceSearch

https://coolfishgames.com/js/scroll.js

js coolfishgames.com collected 2026-10-02 15:51:57 UTC 2,710 bytes, 86 lines download raw bytes

1function intval(v){  
2    v = parseInt(v);  
3    return isNaN(v) ? 0 : v;  
4} // ?取元素信息     
5function getPos(e){  
6    var l = 0;  
7    var t = -100;  
8    var w = intval(e.style.width);  
9    var h = intval(e.style.height);  
10    var wb = e.offsetWidth;  
11    var hb = e.offsetHeight;  
12    while (e.offsetParent) {  
13        l += e.offsetLeft + (e.currentStyle ? intval(e.currentStyle.borderLeftWidth) : 0);  
14        t += e.offsetTop + (e.currentStyle ? intval(e.currentStyle.borderTopWidth) : 0);  
15        e = e.offsetParent;  
16    }  
17    l += e.offsetLeft + (e.currentStyle ? intval(e.currentStyle.borderLeftWidth) : 0);  
18    t += e.offsetTop + (e.currentStyle ? intval(e.currentStyle.borderTopWidth) : 0);  
19    return {  
20        x: l,  
21        y: t,  
22        w: w,  
23        h: h,  
24        wb: wb,  
25        hb: hb  
26    };  
27} // ?取??条信息     
28function getScroll(){  
29    var t, l, w, h;  
30    if (document.documentElement && document.documentElement.scrollTop) {  
31        t = document.documentElement.scrollTop;  
32        l = document.documentElement.scrollLeft;  
33        w = document.documentElement.scrollWidth;  
34        h = document.documentElement.scrollHeight;  
35    }  
36    else  
37        if (document.body) {  
38            t = document.body.scrollTop;  
39            l = document.body.scrollLeft;  
40            w = document.body.scrollWidth;  
41            h = document.body.scrollHeight;  
42        }  
43    return {  
44        t: t,  
45        l: l,  
46        w: w,  
47        h: h  
48    };  
49} // ?点(Anchor)?平滑跳?     
50function scroller(el, duration){  
51    if (typeof el != 'object') {  
52        el = document.getElementById(el);  
53    }  
54    if (!el)  
55        return;  
56    var z = this;  
57    z.el = el;  
58    z.p = getPos(el);  
59    z.s = getScroll();  
60    z.clear = function(){  
61        window.clearInterval(z.timer);  
62        z.timer = null  
63    };  
64    z.t = (new Date).getTime();  
65    z.step = function(){  
66        var t = (new Date).getTime();  
67        var p = (t - z.t) / duration;  
68        if (t >= duration + z.t) {  
69            z.clear();  
70            window.setTimeout(function(){  
71                z.scroll(z.p.y, z.p.x)  
72            }, 13);  
73        }  
74        else {  
75            st = ((-Math.cos(p * Math.PI) / 2) + 0.5) * (z.p.y - z.s.t) + z.s.t;  
76            sl = ((-Math.cos(p * Math.PI) / 2) + 0.5) * (z.p.x - z.s.l) + z.s.l;  
77            z.scroll(st, sl);  
78        }  
79    };  
80    z.scroll = function(t, l){  
81        window.scrollTo(l, t)  
82    };  
83    z.timer = window.setInterval(function(){  
84        z.step();  
85    }, 13);  
86}  

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.