PageSourceSearch

https://www.teflcourse.net/js/animatescroll.js

js teflcourse.net collected 2026-10-02 11:38:26 UTC 8,202 bytes, 183 lines download raw bytes

vendor: 5,504 bytes, lines 1-115
1/*
2 * @build  : 20-07-2013
3 * @author : Ram swaroop
4 * @site   : Compzets.com
5 */
6(function ($) {
7
8    // defines various easing effects
9    $.easing['jswing'] = $.easing['swing'];
10    $.extend($.easing,
11        {
12            def: 'easeOutQuad',
13            swing: function (x, t, b, c, d) {
14                return $.easing[$.easing.def](x, t, b, c, d);
15            },
16            easeInQuad: function (x, t, b, c, d) {
17                return c * (t /= d) * t + b;
18            },
19            easeOutQuad: function (x, t, b, c, d) {
20                return -c * (t /= d) * (t - 2) + b;
21            },
22            easeInOutQuad: function (x, t, b, c, d) {
23                if ((t /= d / 2) < 1) return c / 2 * t * t + b;
24                return -c / 2 * ((--t) * (t - 2) - 1) + b;
25            },
26            easeInCubic: function (x, t, b, c, d) {
27                return c * (t /= d) * t * t + b;
28            },
29            easeOutCubic: function (x, t, b, c, d) {
30                return c * ((t = t / d - 1) * t * t + 1) + b;
31            },
32            easeInOutCubic: function (x, t, b, c, d) {
33                if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
34                return c / 2 * ((t -= 2) * t * t + 2) + b;
35            },
36            easeInQuart: function (x, t, b, c, d) {
37                return c * (t /= d) * t * t * t + b;
38            },
39            easeOutQuart: function (x, t, b, c, d) {
40                return -c * ((t = t / d - 1) * t * t * t - 1) + b;
41            },
42            easeInOutQuart: function (x, t, b, c, d) {
43                if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
44                return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
45            },
46            easeInQuint: function (x, t, b, c, d) {
47                return c * (t /= d) * t * t * t * t + b;
48            },
49            easeOutQuint: function (x, t, b, c, d) {
50                return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
51            },
52            easeInOutQuint: function (x, t, b, c, d) {
53                if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
54                return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
55            },
56            easeInSine: function (x, t, b, c, d) {
57                return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
58            },
59            easeOutSine: function (x, t, b, c, d) {
60                return c * Math.sin(t / d * (Math.PI / 2)) + b;
61            },
62            easeInOutSine: function (x, t, b, c, d) {
63                return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
64            },
65            easeInExpo: function (x, t, b, c, d) {
66                return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
67            },
68            easeOutExpo: function (x, t, b, c, d) {
69                return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
70            },
71            easeInOutExpo: function (x, t, b, c, d) {
72                if (t == 0) return b;
73                if (t == d) return b + c;
74                if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
75                return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
76            },
77            easeInCirc: function (x, t, b, c, d) {
78                return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
79            },
80            easeOutCirc: function (x, t, b, c, d) {
81                return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
82            },
83            easeInOutCirc: function (x, t, b, c, d) {
84                if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
85                return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
86            },
87            easeInElastic: function (x, t, b, c, d) {
88                var s = 1.70158; var p = 0; var a = c;
89                if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
90                if (a < Math.abs(c)) { a = c; var s = p / 4; }
91                else var s = p / (2 * Math.PI) * Math.asin(c / a);
92                return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
93            },
94            easeOutElastic: function (x, t, b, c, d) {
95                var s = 1.70158; var p = 0; var a = c;
96                if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
97                if (a < Math.abs(c)) { a = c; var s = p / 4; }
98                else var s = p / (2 * Math.PI) * Math.asin(c / a);
99                return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
100            },
101            easeInOutElastic: function (x, t, b, c, d) {
102                var s = 1.70158; var p = 0; var a = c;
103                if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; if (!p) p = d * (.3 * 1.5);
104                if (a < Math.abs(c)) { a = c; var s = p / 4; }
105                else var s = p / (2 * Math.PI) * Math.asin(c / a);
106                if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
107                return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
108            },
109            easeInBack: function (x, t, b, c, d, s) {
110                if (s == undefined) s = 1.70158;
111                return c * (t /= d) * t * ((s + 1) * t - s) + b;
112            },
113            easeOutBack: function (x, t, b, c, d, s) {
114                if (s == undefined) s = 1.70158;
115                return c * ((t = t / d - 1) * t * ((s + 1) * t + s
115) + 1) + b;
116            },
117            easeInOutBack: function (x, t, b, c, d, s) {
118                if (s == undefined) s = 1.70158;
119                if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
120                return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
121            },
122            easeInBounce: function (x, t, b, c, d) {
123                return c - $.easing.easeOutBounce(x, d - t, 0, c, d) + b;
124            },
125            easeOutBounce: function (x, t, b, c, d) {
126                if ((t /= d) < (1 / 2.75)) {
127                    return c * (7.5625 * t * t) + b;
128                } else if (t < (2 / 2.75)) {
129                    return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
130                } else if (t < (2.5 / 2.75)) {
131                    return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
132                } else {
133                    return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
134                }
135            },
136            easeInOutBounce: function (x, t, b, c, d) {
137                if (t < d / 2) return $.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
138                return $.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
139            }
140        });
141
142    $.fn.animatescroll = function (options) {
143
144        // fetches options
145        var opts = $.extend({}, $.fn.animatescroll.defaults, options);
146
147        // make sure the callback is a function
148        if (typeof opts.onScrollStart == 'function') {
149            // brings the scope to the callback
150            opts.onScrollStart.call(this);
151        }
152
153        if (opts.element == "html,body") {
154            // Get the distance of particular id or class from top
155            var offset = this.offset().top;
156
157            // Scroll the page to the desired position
158            $(opts.element).stop().animate({ scrollTop: offset - opts.padding }, opts.scrollSpeed, opts.easing);
159        }
160        else {
161            // Scroll the element to the desired position
162            $(opts.element).stop().animate({ scrollTop: this.offset().top - this.parent().offset().top + this.parent().scrollTop() - opts.padding }, opts.scrollSpeed, opts.easing);
163        }
164
165        setTimeout(function () {
166
167            // make sure the callback is a function
168            if (typeof opts.onScrollEnd == 'function') {
169                // brings the scope to the callback
170                opts.onScrollEnd.call(this);
171            }
172        }, opts.scrollSpeed);
173    };
174
175    // default options
176    $.fn.animatescroll.defaults = {
177        easing: "swing",
178        scrollSpeed: 800,
179        padding: 0,
180        element: "html,body"
181    };
182
183}(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.