how should scrollto for webcontainers work?

I have a webcontainer within another webcontainer, and I’d like the child container to scroll within the parent container. I have the following code in the mousedown event of a label control, and it It seems like it should work to scroll the child container:

self.mainScreenBackGroundContainer1.mainScreenBackground1.ScrollTo(self.mainScreenBackGroundContainer1.mainScreenBackground1.left,-300)

Shouldn’t that scroll the child container 300 pixels up within the parent container? Although the mousedown event fires and the scrollto line appears to run, the scrollto command appears to do nothing. It doesn’t trigger the contentscrolled event of the parent container as I think it should. Any ideas as to what I am doing wrong?

Another general question about scrollto … if it does work, is it an animated scroll?

Thanks,
Kevin Clark

First things first. The method scrolls TO a position, not by the amounts you supply, so the x and y values have a minimum of 0. I’m not in front of my computer, but it may be that it ignores values < 0.

As far as animation, that’s up to the individual browsers, so the best answer I can give you is “maybe”. Keep in mind that if it does work today, it may not in the next release of that particular browser.

I wonder what the rationale would be for having a minimum value of 0. You can set the top of the child container to less than 0, so why not be able to scrollto a number less than 0? I have tried scrollto with positive numbers and I haven’t been able to get that work either. But if the animation isn’t reliable, then maybe it’s better just to use top instead of scrollto.

Because that’s all that JavaScript offers. If you were to set the top of the child container to -100, that means that the parent container has a scrollY value of 100. Setting it to zero should move the top of the child container to be equal to the top of the parent.

Ah, I think I get it now. I had a conceptually wrong idea of what scrollto does. It doesn’t move the container itself, but moves the contents of the container. I’ve been trying to use scrollto on the child container, when I should have been using it on the parent container.

Now you’ve got it!