Problem Description
The postlayout event is fired twice, therefore the callback is called twice as well.
Steps to reproduce
1. Create a new mobile project (Classic Titanium)
2. Paste the code sample to app.js
3. Run the code in the simulator
4. Please check the console when running, you will be able to see that the width and the height value are changing twice. They should change once.
[INFO] : e.source.rect.width 320
[INFO] : e.source.rect.height 216
[INFO] : e.source.rect.width 320
[INFO] : e.source.rect.height 216
Test case
var win = Ti.UI.createWindow();
var btn = Ti.UI.createButton();
win.setLeftNavButton(btn);
btn.addEventListener('click', function(e) {
win.close();
});
var picker = Ti.UI.createPicker({
type : Ti.UI.PICKER_TYPE_DATE,
minDate : new Date(2009, 0, 1),
maxDate : new Date(2014, 11, 31),
value : new Date(2014, 3, 12),
visible : true
});
var view = Ti.UI.createView({
bottom : -279,
width : Ti.UI.SIZE,
height : Ti.UI.SIZE
});
var slide_in = Titanium.UI.createAnimation({
bottom : 0,
duration : 200,
});
var slide_out = Titanium.UI.createAnimation({
bottom : -304,
duration : 200
});
view.addEventListener("postlayout", function(e) {
Ti.API.info('e.source.rect.width'+e.source.rect.width);
Ti.API.info('e.source.rect.height'+e.source.rect.height);
});
view.add(picker);
win.add(view);
win.open();
Issue reproduces Titanium Command-Line Interface, CLI version 3.3.0, Titanium SDK version 3.3.0.GA iOS SDK: 7.1 iOS iPhone Simulator: 7.1
Can confirm that this is still an issue. Tested with the following environment; iPhone 7 (10.2) MacOS 10.11.6 (15G31) Studio 4.9.0.201705021158 Ti SDK 6.1.0.v20170519131839 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.7.0_80