views:

284

answers:

0

Hi! I have a simple animation on group of images, made with GWT 2.0. Images is situated on AbsolutePanel. Animation always goes on one axis (x or y). When the panel has no style, added by addStyleName(...), animation is fine. But if i set the style, wich contains "border: ... ;", animation become on both axis synchronously! How can i fix this problem? Animation code:

protected void moveImageTo(final Image img, Move direction) { if (direction == null) return;

    int dX = 0, dY = 0;
    final int offset = 5;

    switch (direction) {
        case LEFT:
            dX = -offset;
            break;

        case RIGHT:
            dX = offset;
            break;

        case UP:
            dY = -offset;
            break;

        case DOWN:
            dY = offset;
            break;

        default:
            return;
    }

    final int _dX = dX, _dY = dY;    

    Timer t = new Timer() {
        int i = 0;

        public void run() {
            p.setWidgetPosition(img, _dX + p.getWidgetLeft(img), _dY + p.getWidgetTop(img));

            if ((i += offset) >= sqSide) { 
                checkForWin();
                cancel();
            }
        }
    };

    t.scheduleRepeating(10);
}