Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2774] Android: Animation and Center 1.5.1 and 1.6.0 Results

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T02:00:03.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.6.0 M04
ComponentsAndroid
Labelsandroid, enterprise, feature, release-1.6.0, rplist
ReporterFred Spencer
AssigneeDon Thorp
Created2011-04-15T03:29:11.000+0000
Updated2011-04-17T02:00:03.000+0000

Description

See attached video for comparison demo.

var win = Ti.UI.createWindow({
    navBarHidden:true,
    exitOnClose:true,
    backgroundColor: '#fff'
});

var view = Ti.UI.createView({
    // initial setting of of a small box view that is centered
    width: 10,
    height: 10,
    center: {
        x: Ti.Platform.displayCaps.platformWidth / 2,
        y: Ti.Platform.displayCaps.platformHeight / 2
    },
    backgroundColor: '#f00'
});

var openBtn = Ti.UI.createButton({
    left: 10,
    right: 10,
    height: 50,
    title: 'Open'
});

openBtn.addEventListener('click', function(e) {
    var closeBtn = Ti.UI.createButton({
        left: 10,
        right: 10,
        height: 50,
        title: 'Close'
    });

    closeBtn.addEventListener('click', function(e) {
        view.remove(closeBtn);

        view.animate({
            center: {
                x: Ti.Platform.displayCaps.platformWidth / 2,
                y: Ti.Platform.displayCaps.platformHeight / 2
            },
            width: 10,
            height: 10,
            duration: 300
        },
        function(e) {
            win.remove(view);
            Ti.API.info('This is going to be called multiple times.');
        });
    });

    win.add(view);

    // animate small, centered box
    view.animate({
        center: {
            x: Ti.Platform.displayCaps.platformWidth / 2,
            y: Ti.Platform.displayCaps.platformHeight / 2
        },
        width: Ti.Platform.displayCaps.platformWidth,
        height: Ti.Platform.displayCaps.platformHeight,
        duration: 300
    },
    function(e) {
        view.add(closeBtn);
        Ti.API.info('This is going to be called multiple times.');
    });
});

win.add(openBtn);
win.open();

Attachments

FileDateSize
151.MOV2011-04-15T03:29:12.000+00001098493
160.MOV2011-04-15T03:29:13.000+00001696653
screen-shot-2011-01-07-at-33351-pm.png2011-04-15T03:29:12.000+000016065
screen-shot-2011-01-07-at-33846-pm.png2011-04-15T03:29:12.000+0000104810

Comments

  1. Marshall Culpepper 2011-04-15

    the "center" property wasn't implemented before a few days ago. If you want a truly centered view shouldn't you be using center: { x: 0, y: 0 } ? Dividing platformHeight/platformWidth by two would be good for top and left, but not center x/y?

  2. Fred Spencer 2011-04-15

    I suppose this has to do with expectation. Is the view centered relative to it's parent and where is the parent's coordinate origin?

    In a layout tool, if the origin starts in the upper left (0,0), then the relative position of the element positioned on top would be width/2, height/2.

    Originally, this worked on both iOS and Android (as seen in video) as relative to the parents origin at (0,0), upper-left.

    Screenshot one: Where is it?
    Screenshot two: How 0,0 works on iOS

  3. Marshall Culpepper 2011-04-15

    Ahh.. I guess I was under the impression that "center" was relative to the parent's center position. This never actually "worked" in Android because the center property wasn't even implemented until a few days ago, so my guess is the values you had were incidental with some of our default behaviors :)

  4. Marshall Culpepper 2011-04-15

    (from [eecab83e319ad70b79af913fbc3ad0d99f8265bc]) center positions are parent-relative to 0,0 instead of parent-center relative [#2774 state:fixed-in-qa]
    https://github.com/appcelerator/titanium_mobile/commit/eecab83e319ad70b79af913fbc3ad0d99f8265bc"> https://github.com/appcelerator/titanium_mobile/commit/eecab83e319a...

  5. Thomas Huelbert 2011-04-15

    sim 2.2, G1 (1.6) [INFO] Titanium SDK version: 1.5.2 (01/10/11 08:22 682e79e) and [INFO] Titanium SDK version: 1.6.0 (01/10/11 08:25 3452f06)

JSON Source