Is there any way to disable the ScrollTo() animation in WebContainers? Or perhaps speed it up dramatically?
I have two WebContainers that I want to have scroll in sync. I do this by calling ScrollTo() on the second container from the ContentScrolled event of the first. Unfortunately, there’s a lag twixt the two. While I accept that this is the case, it would be much less apparent if the animation was turned off in the second container so that the ScrollTo was instantaneous, rather than animated.
There may be a way, but all depends on the complexity of your layout. And this is just ideas. Please take them with a grain of salt.
I tried with two WebContainers side by side scrolling vertically. WCC1 and WCC2.
Instead of placing WCC2 on the Webpage, I placed it’s instance on WCC1, at the location it should show relative to WCC1 (out of the WCC1 default area), and enlarged it so it shows all its content.
On the WebPage I enlarged the width of the WWC1 instance so it shows both containers. Now everything scrolls in sync. The only catch is that the scrollbar shows only on the right hand side container. You will have to use an additional scrollbar for the first one and sync it from inside the code.
Of course this would be more complex if they were spread up across diagonally, over lots of other controls. In such a case, you would need to mask the scrollbars to avoid them to show much too long. And use rectangles to create windows under which the container controls will show. it would not be possible if they should scroll in all directions. Also, you want to make sure to position other controls in front of the container to prevent it from stealing mouse clicks and wheel.
I also tried what you do, and I believe the problem is less animation than the number of times ContentScrolled fires. With a System.Debuglog it shows it firing every other point or so during a scroll, creating a huge amount of traffic and calling ScrollTo a heavy number of times. You may be able to speed up the process by trimming the number of times the event calls ScrollTo. For instance by calling ScrollTo on a set number milliseconds. I guess 33 is probably alright : it is 1/30 th of a second, quicker than the perception of the human eye.
I have worked around the issue of multiple ContentScrolled event firings. The issue is that when you scroll there’s an animation with a decelerating speed, so that the scroll looks more natural. I just want to stop that from happening and have no animation (i.e. the scroll move occurs instantly).