From bbc06d64493bf30feed25a379905d8312e6ba2e8 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 25 Aug 2011 09:21:41 +0000 Subject: When scrollbar extents are updated, scale current offset appropriately. svn path=/trunk/netsurf/; revision=12667 --- desktop/scrollbar.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'desktop') diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c index 6dd9b0b15..b84ed08a1 100644 --- a/desktop/scrollbar.c +++ b/desktop/scrollbar.c @@ -458,8 +458,7 @@ void scrollbar_set_extents(struct scrollbar *s, int length, int visible_size, int full_size) { int well_length; - - /* TODO: update offset appropriately */ + int cur_excess = s->full_size - s->visible_size; if (length != -1) s->length = length; @@ -468,6 +467,9 @@ void scrollbar_set_extents(struct scrollbar *s, int length, if (full_size != -1) s->full_size = full_size; + /* Update scroll offset (scaled in proportion with change in excess) */ + s->offset = (s->full_size - s->visible_size) * s->offset / cur_excess; + well_length = s->length - 2 * SCROLLBAR_WIDTH; s->bar_len = (well_length * s->visible_size) / s->full_size; -- cgit v1.2.3