summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAugust Lilleaas <augustlilleaas@gmail.com>2009-06-12 10:43:55 +0200
committerAugust Lilleaas <augustlilleaas@gmail.com>2009-06-12 10:50:17 +0200
commitccc65ff92bbbe40e49683dd031e99d3c3d1f558e (patch)
tree606c08071cdd4744a109e60191ebef3c4c8f7c14
parent86ff70a4e3cb14df0d4d3c9eb2194b6ee03e666c (diff)
downloadgitorious-mainline-outdated-ccc65ff92bbbe40e49683dd031e99d3c3d1f558e.zip
gitorious-mainline-outdated-ccc65ff92bbbe40e49683dd031e99d3c3d1f558e.tar.gz
gitorious-mainline-outdated-ccc65ff92bbbe40e49683dd031e99d3c3d1f558e.tar.bz2
Stopping the scrolling animation when hovering the scroller.
-rw-r--r--public/javascripts/application.js35
1 files changed, 23 insertions, 12 deletions
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 6efba66..816c859 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -222,6 +222,7 @@ Event.observe(window, "load", function(e){
var LOAD_MORE_OFFSET = 400;
var currentIteration = 0;
+ var currentAnimTimeout
var getWindowWidth = function(){
@@ -249,21 +250,31 @@ Event.observe(window, "load", function(e){
});
}
- fetchNewBar(function(){
- var animateBar = function(){
- var currentOffset = parseInt(recentActivitiesTarget.getStyle("left"));
- var newOffset = currentOffset - ANIMATION_STEP
- recentActivitiesTarget.setStyle({left: newOffset + "px"});
-
+ var animateBar = function(){
+ var currentOffset = parseInt(recentActivitiesTarget.getStyle("left"));
+ var newOffset = currentOffset - ANIMATION_STEP
+ recentActivitiesTarget.setStyle({left: newOffset + "px"});
+
- if ((BAR_WIDTH * currentIteration) - (getWindowWidth() - newOffset) <= LOAD_MORE_OFFSET) {
- fetchNewBar();
- }
-
- setTimeout(animateBar, FPS);
+ if ((BAR_WIDTH * currentIteration) - (getWindowWidth() - newOffset) <= LOAD_MORE_OFFSET) {
+ fetchNewBar();
}
- animateBar();
+
+ currentAnimTimeout = setTimeout(animateBar, FPS);
+ }
+
+
+ recentActivitiesTarget.observe("mouseover", function(e){
+ clearTimeout(currentAnimTimeout);
});
+
+ recentActivitiesTarget.observe("mouseout", function(e){
+ if (!e.relatedTarget || !e.relatedTarget.descendantOf(this)) {
+ animateBar();
+ }
+ })
+
+ fetchNewBar(animateBar);
}
});