Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't get stuck in overscroll #264

Merged
merged 2 commits into from Apr 25, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Run the overscroll animation all the way to the destination

This fixes a bug where a layer could get "stuck" in overscroll because it gets
within 0.1 of the edge and then stops.
  • Loading branch information
mbrubeck committed Apr 19, 2016
commit b3eb68d6b8e966e7d0b9611e6dd4e9185e9242d3
@@ -1301,10 +1301,7 @@ impl Frame {
let mut layers_bouncing_back = HashSet::with_hasher(Default::default());
for (scroll_layer_id, layer) in &self.layers {
if layer.scrolling.started_bouncing_back {
let overscroll_amount = layer.overscroll_amount();
if overscroll_amount.width.abs() >= 0.1 || overscroll_amount.height.abs() >= 0.1 {
layers_bouncing_back.insert(*scroll_layer_id);
}
layers_bouncing_back.insert(*scroll_layer_id);
}
}
layers_bouncing_back
@@ -114,8 +114,11 @@ impl Layer {
}

pub fn tick_scrolling_bounce_animation(&mut self) {
self.scrolling.spring.animate();
let finished = self.scrolling.spring.animate();
self.scrolling.offset = self.scrolling.spring.current();
if finished {
self.scrolling.started_bouncing_back = false;
}
}
}

@@ -50,7 +50,8 @@ impl Spring {
self.cur
}

pub fn animate(&mut self) {
/// Run one tick of the spring animation. Return true if the animation is complete.
pub fn animate(&mut self) -> bool {
if !is_resting(self.cur.x, self.prev.x, self.dest.x) ||
!is_resting(self.cur.y, self.prev.y, self.dest.y) {
let next = Point2D::new(next(self.cur.x,
@@ -64,10 +65,12 @@ impl Spring {
self.stiffness,
self.damping));
let (cur, dest) = (self.cur, self.dest);
self.coords(next, cur, dest)
self.coords(next, cur, dest);
false
} else {
let dest = self.dest;
self.coords(dest, dest, dest)
self.coords(dest, dest, dest);
true
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.