[Okular-devel] [Bug 152049] Wish: go up or down one page... minus one/N lines

Alexandro Colorado jza at openoffice.org
Sun Jul 31 11:13:19 CEST 2011


https://bugs.kde.org/show_bug.cgi?id=152049


Alexandro Colorado <jza at openoffice.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jza at openoffice.org




--- Comment #17 from Alexandro Colorado <jza openoffice org>  2011-07-31 09:13:18 ---
I would also want to propose an alternative -- somewhat more complex solution.
Of having a "smooth scroll" which is used usually in image galleries which
allow users to go down quickly and slow down as it getting to the next area.
This is a bit of physics and allow the user to catch continuity in it's
reading. Currently the jump of the eyes is also a bit annoying. 
This is also good for touch interfaces and such but some websites also enable
this effect for their sites. 
This is a "web" example of smooth scroll:
http://www.footballmadeinafrica.com/english.html
The organization is a bit different since it derives from a fixed menu. A
reader should have something more fixed to the size of the workspace/view. Here
is a tutorial explaning the code using Javascript:
http://www.itnewb.com/v/Creating-the-Smooth-Scroll-Effect-with-JavaScript

Core script goes like this:
function smoothScroll(eID) {
    var startY = currentYPosition();
    var stopY = elmYPosition(eID);
    var distance = stopY > startY ? stopY - startY : startY - stopY;
    if (distance < 100) {
        scrollTo(0, stopY); return;
    }
    var speed = Math.round(distance / 100);
    if (speed >= 20) speed = 20;
    var step = Math.round(distance / 25);
    var leapY = stopY > startY ? startY + step : startY - step;
    var timer = 0;
    if (stopY > startY) {
        for ( var i=startY; i<stopY; i+=step ) {
            setTimeout("window.scrollTo(0, "+leapY+")", timer * speed);
            leapY += step; if (leapY > stopY) leapY = stopY; timer++;
        } return;
    }
    for ( var i=startY; i>stopY; i-=step ) {
        setTimeout("window.scrollTo(0, "+leapY+")", timer * speed);
        leapY -= step; if (leapY < stopY) leapY = stopY; timer++;
    }
}

The first thing this function does is fetch the start and stop Y coordinates
via the functions covered above. Next, it compares these two values to
determine the distance between them. When setting the distance variable, an
alternate control structure is used to determine which point should be
subtracted from the other (depends on whether it needs to scroll up or down).

 Once the start, stop and distance values are set, a check is done to see
whether the destination element is less than 100 pixels away, and if so it
simply jumps to it. If the destination point is further away the function
continues by dynamically setting the scroll speed (distance divided by 100)
without letting it exceed 20, step size (distance to jump each time the visible
top of page Y coordinate is changed, thus moving closer to the destination),
the leapY (next coordinate to jump to) and the initial timer value of 0.

 At this point, a check is performed to determine whether the destination point
is greater than the starting point (scrolling down). If so, the if is entered
and the scroll is performed otherwise the for loop at the very bottom is hit,
which performs an upward scroll.

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Okular-devel mailing list