Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to scroll to an offscreen canvas?

    This is probably obvious, but I'm having a heck of a time getting a widget off screen in the viewport to scroll into view. Assume I have VLayout with Overflow set to Auto, and I've added 3 members to it a, b, and c. Like this:

    Code:
    VLayout canvas = new VLayout();
    canvas.setOverflow(Overflow.AUTO);
    ...
    VLayout a = new VLayout();
    ..
    canvas.addMember(a);
    VLayout b = new VLayout();
    ..
    canvas.addMember(b);
    VLayout c = new VLayout();
    ..
    canvas.addMember(c);
    I'd then like to do something like:

    Code:
    canvas.scrollTo(c)
    that would scroll down to c bringing it into view. How do I do this?

    Thanks!

    #2
    If you're placing it offscreen at negative left or top coordinates, it cannot be scrolled to (by design: browsers won't do this, and it violates relevant specs).

    Comment


      #3
      I want to do the opposite - panel c is scrolled out of view, and I want to programatically scroll it back into view. I can get it to scroll down toward member c by calling

      Code:
      canvas.scrollTo(0, 200);
      However, I don't know how far to scroll it.

      Thanks!
      Chris

      Comment


        #4
        You can use getLeft() / getTop() / getWidth() / getHeight() to figure out the coordinates of the target canvas, and scroll to the appropriate spot based on these (so at the simplest just parentWidget.scrollTo(childWidget.getLeft(), childWidget.getTop());)

        Comment

        Working...
        X