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 all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -634,7 +634,8 @@ impl Frame {
}

let overscroll_amount = layer.overscroll_amount();
let overscrolling = overscroll_amount.width != 0.0 || overscroll_amount.height != 0.0;
let overscrolling = CAN_OVERSCROLL && (overscroll_amount.width != 0.0 ||
overscroll_amount.height != 0.0);
if overscrolling {
if overscroll_amount.width != 0.0 {
delta.x /= overscroll_amount.width.abs()
@@ -676,7 +677,9 @@ impl Frame {
layer.scrolling.offset.x = layer.scrolling.offset.x.round();
layer.scrolling.offset.y = layer.scrolling.offset.y.round();

layer.stretch_overscroll_spring();
if CAN_OVERSCROLL {
layer.stretch_overscroll_spring();
}
}

pub fn tick_scrolling_bounce_animations(&mut self) {
@@ -1301,10 +1304,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.