1(function(){ 2 var scrollY = window.scrollY || window.pageYOffset || document.documentElement.scrollTop; 3 var scrollTargetY = 0; 4 var currentTime = 0; 5 var time = null; 6 var p = null; 7 var t = null; 8 var easing = 'easeOutSine'; 9 10 // Ecuaciones easing de https://github.com/danro/easing-js/blob/master/easing.js. 11 var easingEquations = { 12 easeOutSine: function( pos ){ 13 return Math.sin( pos * ( Math.PI / 2 ) ); 14 }, 15 easeInOutSine: function( pos ){ 16 return ( -0.5 * ( Math.cos ( Math.PI * pos ) - 1 ) ); 17 }, 18 easeInOutQuint: function( pos ){ 19 if( ( pos /= 0.5 ) < 1 ){ 20 return 0.5 * Math.pow( pos, 5 ); 21 } 22 return 0.5 * ( Math.pow( ( pos - 2 ), 5 ) + 2 ); 23 } 24 }; 25 26 /** 27 * Smooth Vertical Scrolling. 28 * 29 * @param {string} scrollTargetY - Número > 0 de "pixeles" del scroll vertical de un target. Ej: el.offsetTop. 30 * @param {object} speed - tiempo en pixeles por segundo. 31 */ 32 function scrollToY( scrollTargetY, speed ) { 33 34 scrollTargetY = scrollTargetY || 0; 35 speed = speed || 2000; 36 37 // Reseteamos variables para los próximos click del usuario. 38 p = 0; 39 currentTime = 0; 40 41 // Min time .1, Max time .8 segundos. 42 time = Math.max( .1, Math.min( Math.abs( scrollY - scrollTargetY ) / speed, .8 ) ); 43 44 // Ejecutamos una vez para comenzar 45 tick(); 46 } 47 48 // Add loop de animación. 49 function tick() { 50 51 currentTime += 1 / 60; 52 53 p = currentTime / time; 54 t = easingEquations[ easing ]( p ); 55 56 if ( p < 1 ) { 57 requestAnimationFrame( tick ); 58 59 window.scrollTo( 0, scrollY + ( ( scrollTargetY - scrollY ) * t ) ); 60 } else { 61 // Finalización del scroll. 62 window.scrollTo( 0, scrollTargetY ); 63 } 64 } 65 66 window.scrollToY = scrollToY; 67})();
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.