1/* 2 * magician.js v1.0.0 3 * (c) 2019 Oxaim 4 * Released under the MIT license 5 * http://oxa.im 6 */ 7 8(function( $ ) { 9 "use strict"; 10 $.fn.magician = function( options ) { 11 12 const debug = false; 13 const scriptName = 'magicianJS'; 14 const scriptVersion = '1.0'; 15 16 var settings = $.extend({ 17 // These are the defaults. 18 container: $(window), 19 type: 'scroll', 20 offsetTop: 0, 21 duration: 1000, 22 offsetBottom: 0, 23 animation: {} 24 }, options ); 25 26 var $container, 27 $target, 28 29 docViewHeight, 30 docViewTop, 31 docViewBottom, 32 eHeight, 33 eTop, 34 eBottom, 35 animationObject, 36 37 scrollPosPrev, 38 scrollPos; 39 40 41 42 43 44 45 // helpers 46 var setPosition = function(){ 47 docViewHeight = $container.height() - (settings.offsetTop + settings.offsetBottom); 48 docViewTop = $container.scrollTop() + settings.offsetTop; 49 docViewBottom = docViewTop + docViewHeight; 50 eHeight = $target.outerHeight(); 51 eTop = $target.offset().top; 52 eBottom = eTop + eHeight; 53 return; 54 } 55 56 var isInView = function(){ 57 return ((eTop <= docViewBottom) && (eBottom >= docViewTop)); 58 } 59 60 var log = function($var, $indentifier){ 61 if(debug == true){ 62 if($indentifier !== undefined){ 63 //console.log("\n \n/" + $indentifier + '/'); 64 } 65 //console.log($var); 66 } 67 } 68 69 70 // machalisms 71 var scrollMachalism = function(){ 72 setPosition(); 73 if(isInView($target) == true){ 74 scrollPos = (docViewTop - eTop) + (docViewHeight); 75 }else{ 76 if(eTop <= docViewBottom){ 77 scrollPos = docViewHeight + eHeight; 78 } 79 if(eBottom >= docViewTop){ 80 scrollPos = 0; 81 } 82 } 83 scrollPos = Math.floor((scrollPos / (docViewHeight + eHeight)) * 1000); 84 85 $({ n: scrollPosPrev }).animate({ n: scrollPos}, { 86 duration: settings.duration, 87 easing: 'easeOutQuad', 88 step: function(now, fx) {
vendor: 4,355 bytes, lines 89-214
89 animationObject.seek(now); 90 }, 91 }); 92 scrollPosPrev = scrollPos; 93 94 } 95 96 97 98 // constructor 99 this.each(function() { 100 $target = $(this); 101 $container = (typeof settings.container == 'object') ? settings.container : $target.parents(settings.container).eq(0); 102 //log($container); 103 104 switch(settings.type){ 105 case 'scroll': 106 var animation = $.extend(settings.animation, { 107 targets: $target.get(), 108 duration: 1000, 109 elasticity: 0, 110 easing: 'linear', 111 autoplay: false 112 }); 113 114 log(animation); 115 animationObject = anime(animation); 116 117 scrollMachalism(); 118 119 $container.on('scroll', scrollMachalism); 120 break; 121 122 case 'mousemove': 123 var relX = e.pageX - $target.offset().left; 124 var relY = e.pageY - $target.offset().top; 125 126 TweenMax.to($target.find('.elementor-repeater-item-' + obj._id), 1, { 127 x: (relX - $target.width() / 2) / $target.width() * obj.parallax_speed, 128 y: (relY - $target.height() / 2) / $target.height() * obj.parallax_speed, 129 ease: Power2.ease 130 }); 131 break; 132 } 133 }); 134 return this; 135 }; 136 137 138jQuery.easing['jswing'] = jQuery.easing['swing']; 139 140jQuery.extend( jQuery.easing, 141{ 142 def: 'easeOutQuad', 143 swing: function (x, t, b, c, d) { 144 //alert(jQuery.easing.default); 145 return jQuery.easing[jQuery.easing.def](x, t, b, c, d); 146 }, 147 easeInQuad: function (x, t, b, c, d) { 148 return c*(t/=d)*t + b; 149 }, 150 easeOutQuad: function (x, t, b, c, d) { 151 return -c *(t/=d)*(t-2) + b; 152 }, 153 easeInOutQuad: function (x, t, b, c, d) { 154 if ((t/=d/2) < 1) return c/2*t*t + b; 155 return -c/2 * ((--t)*(t-2) - 1) + b; 156 }, 157 easeInCubic: function (x, t, b, c, d) { 158 return c*(t/=d)*t*t + b; 159 }, 160 easeOutCubic: function (x, t, b, c, d) { 161 return c*((t=t/d-1)*t*t + 1) + b; 162 }, 163 easeInOutCubic: function (x, t, b, c, d) { 164 if ((t/=d/2) < 1) return c/2*t*t*t + b; 165 return c/2*((t-=2)*t*t + 2) + b; 166 }, 167 easeInQuart: function (x, t, b, c, d) { 168 return c*(t/=d)*t*t*t + b; 169 }, 170 easeOutQuart: function (x, t, b, c, d) { 171 return -c * ((t=t/d-1)*t*t*t - 1) + b; 172 }, 173 easeInOutQuart: function (x, t, b, c, d) { 174 if ((t/=d/2) < 1) return c/2*t*t*t*t + b; 175 return -c/2 * ((t-=2)*t*t*t - 2) + b; 176 }, 177 easeInQuint: function (x, t, b, c, d) { 178 return c*(t/=d)*t*t*t*t + b; 179 }, 180 easeOutQuint: function (x, t, b, c, d) { 181 return c*((t=t/d-1)*t*t*t*t + 1) + b; 182 }, 183 easeInOutQuint: function (x, t, b, c, d) { 184 if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; 185 return c/2*((t-=2)*t*t*t*t + 2) + b; 186 }, 187 easeInSine: function (x, t, b, c, d) { 188 return -c * Math.cos(t/d * (Math.PI/2)) + c + b; 189 }, 190 easeOutSine: function (x, t, b, c, d) { 191 return c * Math.sin(t/d * (Math.PI/2)) + b; 192 }, 193 easeInOutSine: function (x, t, b, c, d) { 194 return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; 195 }, 196 easeInExpo: function (x, t, b, c, d) { 197 return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; 198 }, 199 easeOutExpo: function (x, t, b, c, d) { 200 return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; 201 }, 202 easeInOutExpo: function (x, t, b, c, d) { 203 if (t==0) return b; 204 if (t==d) return b+c; 205 if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; 206 return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; 207 }, 208 easeInCirc: function (x, t, b, c, d) { 209 return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; 210 }, 211 easeOutCirc: function (x, t, b, c, d) { 212 return c * Math.sqrt(1 - (t=t/d-1)*t) + b; 213 }, 214 easeInOutCirc: function (x, t, b, c, d) {
vendor: 2,645 bytes, lines 215-273
215 if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; 216 return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; 217 }, 218 easeInElastic: function (x, t, b, c, d) { 219 var s=1.70158;var p=0;var a=c; 220 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 221 if (a < Math.abs(c)) { a=c; var s=p/4; } 222 else var s = p/(2*Math.PI) * Math.asin (c/a); 223 return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 224 }, 225 easeOutElastic: function (x, t, b, c, d) { 226 var s=1.70158;var p=0;var a=c; 227 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 228 if (a < Math.abs(c)) { a=c; var s=p/4; } 229 else var s = p/(2*Math.PI) * Math.asin (c/a); 230 return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; 231 }, 232 easeInOutElastic: function (x, t, b, c, d) { 233 var s=1.70158;var p=0;var a=c; 234 if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); 235 if (a < Math.abs(c)) { a=c; var s=p/4; } 236 else var s = p/(2*Math.PI) * Math.asin (c/a); 237 if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 238 return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; 239 }, 240 easeInBack: function (x, t, b, c, d, s) { 241 if (s == undefined) s = 1.70158; 242 return c*(t/=d)*t*((s+1)*t - s) + b; 243 }, 244 easeOutBack: function (x, t, b, c, d, s) { 245 if (s == undefined) s = 1.70158; 246 return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; 247 }, 248 easeInOutBack: function (x, t, b, c, d, s) { 249 if (s == undefined) s = 1.70158; 250 if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 251 return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 252 }, 253 easeInBounce: function (x, t, b, c, d) { 254 return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b; 255 }, 256 easeOutBounce: function (x, t, b, c, d) { 257 if ((t/=d) < (1/2.75)) { 258 return c*(7.5625*t*t) + b; 259 } else if (t < (2/2.75)) { 260 return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; 261 } else if (t < (2.5/2.75)) { 262 return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; 263 } else { 264 return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; 265 } 266 }, 267 easeInOutBounce: function (x, t, b, c, d) { 268 if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; 269 return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; 270 } 271}); 272 273}( 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.