Titanium JIRA Archive
Appcelerator Community (AC)

[AC-3282] iOS: DashboardView: don't recreate items on frame change

GitHub Issuen/a
TypeImprovement
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2012-09-10T15:44:38.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterRussell Frank
AssigneeBetty Tran
Created2012-09-05T13:03:36.000+0000
Updated2016-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.

Comments

  1. Russell Frank 2012-09-05

    Pull request opened on Github: [#2871](https://github.com/appcelerator/titanium_mobile/pull/2871)
  2. Shak Hossain 2013-12-28

    https://github.com/appcelerator/titanium_mobile/pull/2871 was merged.

JSON Source