[AC-3282] iOS: DashboardView: don't recreate items on frame change
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | n/a |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-09-10T15:44:38.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Russell Frank |
Assignee | Betty Tran |
Created | 2012-09-05T13:03:36.000+0000 |
Updated | 2016-03-08T07:57:42.000+0000 |
Description
When the frame size is changed (which happens on orientation change) the Dashboard View will currently recreate all buttons. This causes them to be animated from the upper left corner of the parent view; they will also occasionally be laid out incorrectly. Instead, we should simply relayout the existing buttons so they animate smoothly to their new position. Here's a test case:
Titanium.UI.setBackgroundColor('#000');
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var dash1 = Ti.UI.createDashboardView({
columnCount: 4,
rowCount: 4
});
var items = [[], [], []];
for (var j = 0; j < 3; j++) {
for (var i = 0; i < 20; i++) {
var item = Ti.UI.createDashboardItem();
item.add(Ti.UI.createLabel({
text: "item numba " + i,
borderColor: '#'+i+'0'+i+'000',
borderWidth: 3,
left: 0, right: 0,
height: 50, width: 50
}));
items[j][i] = item;
}
}
dash1.setData(items[0]);
win1.add(dash1);
win1.open();
win1.addEventListener('click', function (event) {
dash1.stopEditing();
});
A pull request is on the way.
Pull request opened on Github: [#2871](https://github.com/appcelerator/titanium_mobile/pull/2871)
https://github.com/appcelerator/titanium_mobile/pull/2871 was merged.