English 中文(简体)
j roll 食
原标题:jquery scrolling, cant get easing to work

我想提供一个网页,有固定位置和Z-index999。

The goal is to make the div stay on top and all the other content scroll. I got this working properly, however i want to make it "more smooth" with easing, but everything i try makes the script stop working. This is the working script:

 $(document).ready(function(){  
      $( a[href*=#] ).click(function() {  
        if (location.pathname.replace(/^//,  ) == this.pathname.replace(/^//,  )  
        && location.hostname == this.hostname) {  
          var $target = $(this.hash);  
          $target = $target.length && $target  
          || $( [name=  + this.hash.slice(1) + ] );  
          if ($target.length) {  
            var targetOffset = $target.offset().top;  
            $( html,body )  
            .animate({scrollTop: targetOffset}, 1000) ;  
           return false;  
          }  
        }  
      });  
    });`  

任何人都能够帮助我放松感? 我希望,在接近 anchor点时,roll势会迅速放缓。

thanks in advance.

最佳回答

replace

$( html,body ) .animate({scrollTop: targetOffset}, 1000) ;

with

$( html,body ) .animate({scrollTop: targetOffset}, 1000,  easeOutQuart );

Make sure you have included jQuery UI core and jQuery Effects core.

问题回答

暂无回答




相关问题
how to detect Android ListView Scrolling stopped?

I m trying to do something after scrolling stopped.So, I tried using OnScrollListener#onScrollStateChanged(SCROLL_STATE_IDLE) to detect when the scrolling stopped(either TOUCH_SCROLL or FLING)(at 1.5 ...

jQuery - ScrollTo and Serial Scroll not working together

I have tested the scrollTo() plugin, but I need a way to stop the scrolling animation, so I am looking at serialScroll(). Here is what I used with scrollTo: $( #scroller ).scrollTo( 1000px , 3000); ...

Scrolling to the bottom of a div

As part of an ajax chat room (using prototype framework) I am working on I scroll the user to the bottom each time a message is added using the below js. However if the user has scrolled up and the ...

Displaying news with javascript

I keep coming up against this issue. Displaying news on a website. And I d like to come up with a solution to use like a template, something I can just drop on a site easily. The solution I keep ...

UITextview content moves up when textview is selected

I am pretty new to this iPhone dev thing but so far I have built a pretty good app but I have stumbled into this problem that for the life of me I cannot seem to solve. Basically the app is a chat ...

热门标签