Window scroll bar

Hi,
I ran into a bug when using Window.
When I scroll the window by animation, the next time I scroll with the mouse, the scrollBar jumps back and is not in the position relative to where we scrolled.
You can see it in the following code:

const w = new Window({ scrollBarDrag: true, padding: 20 }).center();
const t = new Tile(new Circle(20, red), 4, 20, 20, 20);
w.add(t);

setTimeout(() => {
    w.animate({ props: { scrollY: -200 }, time: 0.3 });
}, 1000);

It only happens when scrolling with the mouse wheel and not when dragging
Tanks,

Hi Hadas - welcome to the ZIM Forum!

Which version of ZIM are you using and on which device are you testing? When we try with ZIM 017 on a computer, it seems to work as expected.

Note, also, that ZIM has interval() and timeout() which has some nice extra features and keeps time in seconds:

timeout(1, ()=>{w.animate({scrollY:-200}, .3)});

@h.almogy ? Any news on this?

Hi @abstract! I'm using ZIM 017 and I have the same problem.
After using the scroll bar, when you scroll with the mouse it starts again from the place where I was holding before using the scroll bar

I have a simple test and can't seem to reproduce. Does it do it for you here:

If not, are you doing anything differently? Can you make a simple test file with the issue.

Do you mean that you use the mouse to drag the scroll bar, then you use the mouse to swipe the window content and the content jumps to where it was before the scroll bar was used? Does it jump before or after the swipe?

What platform and browser are you on?

Thanks

Yes @abstract . This also happens in the example you gave. Try dragging the scroll bar almost to the bottom, then continue scrolling with the mouse wheel. When I do this, the window first jumps to the top (where it was before dragging the scroll bar) and from there continues scrolling again.
I'm on a PC with Windows and the Chrome browser

I dealt with this, using the following code. But I would have expected the Window component to take care of this itself:

document.addEventListener("wheel", (e) => {
    w.scrollY -= e.deltaY;
});

Oh! Scroll wheel. Sorry - missed that in the original post! Okay - we should be able to fix that quite easily then. Just going out now, will have a look this afternoon.

1 Like

Okay - read the post and realized I had not tested scollwheel and then replied - oh... blah blah. But now I actually tried the scrollwheel - and... I still can't reproduce. It does not do that for me. OHHH - if I take off the damp then it does. Okay. Whew. Working on it now.

This has been patched in ZIM 017. Thanks for the report.

1 Like