Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/06/2014, 08:21
PSPforever
 
Fecha de Ingreso: marzo-2008
Mensajes: 186
Antigüedad: 16 años, 1 mes
Puntos: 3
Exclamación Scroll no me funciona en WebKit y Opera

Buenas,

tengo implementado un script que al pulsar en un enlace hace scroll hacia abajo, hacia un punto concreto. Funciona bien en IE y Firefox, pero no en Opera, Safari y Chrome.

Pongo el script:

Código Javascript:
Ver original
  1. (function(){
  2.  
  3.    
  4.     //////////////// VARS ///////////////////////
  5.  
  6.     var $jQ         = jQuery.noConflict(),
  7.         $HdHeight   = $jQ('#header').height(),
  8.         $Wrapper    = $jQ('body,html'),
  9.         $WindowPage = $jQ(window);
  10.  
  11.     /********************************************
  12.                 SC-ANIMATION SCROLL
  13.     *********************************************/
  14.  
  15.     var animationScroll =   animationScroll || {};
  16.  
  17.         animationScroll = {
  18.  
  19.             $ParentElement      :   $jQ('body, html'),
  20.             $NavLink            :   $jQ('#nav a, [data-action="animation-scroll"]'),
  21.  
  22.             init                :   function() {
  23.                                         (this.$NavLink).click(this.animation);
  24.             },
  25.  
  26.             animation           :   function(event) {
  27.                                             var targetHref = this.hash.replace('#','');
  28.                                                 // change class in nav menu
  29.                                                 (animationScroll.$NavLink).removeClass('active');
  30.                                                 $jQ(event.target).addClass('active');
  31.                                                 // animate scroll to section
  32.                                                 (animationScroll.$ParentElement).stop(true,true).animate({
  33.                                                     scrollTop: $jQ("section[id*='" + targetHref + "']").offset().top
  34.                                                 }, 1000);
  35.                                             event.preventDefault();
  36.             }
  37.  
  38.         };
  39.  
  40.     animationScroll.init();
  41.  
  42.  
  43. })();