]> git.lyx.org Git - features.git/commitdiff
* fix random jumps when scrolling very fast using a touchpad or mouse wheel.
authorStefan Schimanski <sts@lyx.org>
Sat, 26 Jan 2008 00:47:22 +0000 (00:47 +0000)
committerStefan Schimanski <sts@lyx.org>
Sat, 26 Jan 2008 00:47:22 +0000 (00:47 +0000)
The problem was this: The value in BufferView::scrollDocView(int value) is
relative to the d->scrollbarParameters_.min/max interval and _not_ absolute.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22675 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp

index 2a543ff5a7e2cf29b573c7e890aa0a51f6a0f68f..e563a4f81d2f4702a5af15c891e05158db0a4706 100644 (file)
@@ -508,7 +508,12 @@ void BufferView::scrollDocView(int value)
                return;
        }
 
-       int par_pos = 0;
+       // cut off at the top
+       if (value < d->scrollbarParameters_.min)
+               value = d->scrollbarParameters_.min;
+
+       // find paragraph at target positin
+       int par_pos = d->scrollbarParameters_.min;
        for (size_t i = 0; i != d->par_height_.size(); ++i) {
                par_pos += d->par_height_[i];
                if (par_pos >= value) {
@@ -521,7 +526,15 @@ void BufferView::scrollDocView(int value)
                << "\tanchor_ref_ = " << d->anchor_pit_
                << "\tpar_pos = " << par_pos);
 
+       // cut off at the end of the buffer
+       if (value > par_pos) {
+               value = d->scrollbarParameters_.max;
+               d->anchor_pit_ = d->par_height_.size() - 1;
+       }
+
+       // set pixel offset of screen to anchor pit
        d->anchor_ypos_ = par_pos - value;
+
        updateMetrics();
        buffer_.changed();
 }