Last active
August 29, 2015 14:27
-
-
Save zazk/d1b524f66d771d53f50a to your computer and use it in GitHub Desktop.
JS. JQuery. Menú animado para secciones. Landing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Función cuando carga la página - OPCIONAL | |
| $(function(){ | |
| // Animacion ------------------------------------------------- | |
| // Para todos los enlaces - Modificar el selector css que necesite | |
| $('a[href*=#]').click(function() { | |
| // Validar los "/" | |
| if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') | |
| && location.hostname == this.hostname) { | |
| //Enlace a Seccion #seccion | |
| var $target = $(this.hash); | |
| // Validar que haya una sección | |
| $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']'); | |
| // Validar la seccion | |
| if ($target.length) { | |
| // Obtener la posición y de la sección a dónde se desea moverse | |
| var targetOffset = $target.offset().top; | |
| // Ejecutar el scroll | |
| $('html,body').animate({scrollTop: targetOffset}, 1000); | |
| // Salir | |
| return false; | |
| } | |
| } | |
| }); | |
| // Final Animacion ------------------------------------------------- | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment