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