Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13737] ListSection.setItems() does not respect {animated:false}

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2016-11-07T07:29:10.000+0000
Affected Version/sRelease 3.1.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterTony Lukasavage
AssigneeEric Merriman
Created2013-05-01T22:05:35.000+0000
Updated2017-03-24T21:57:06.000+0000

Description

problem

[Ti.UI.ListSection.setItems](http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.ListSection-method-setItems) takes a second parameter on iOS that allows you to specify a [ListViewAnimationProperties](http://docs.appcelerator.com/titanium/latest/#!/api/ListViewAnimationProperties) object. In this object one of the properties is *animated*. Setting *animated* to *false* for this parameter should prevent the items from animating down when they are added to the ListView. Despite setting animated to false, the items still animate.

expected

ListItems will be added but not animated when the 2nd parameter to setItems() is set like this
listSection.setItems(arrayOfItems, { animated: false });

test case

You'll notice when running this on iOS that no matter what the value of the object for the second parameter in setItems() the items will still animate down from the top when added.
var ctr = 0;

var win = Ti.UI.createWindow({
	backgroundColor: '#fff'
});
var list = Ti.UI.createListView({
	sections: [Ti.UI.createListSection()]	
});
var button = Ti.UI.createButton({
	title: 'click me'
});
button.addEventListener('click', function(e) {
	ctr++;
	var items = [];
	for (var i = 0; i < ctr; i++) {
		items.push({
			properties: { title: ctr + ' rows' }
		});
	}
	list.sections[0].setItems(items, {animated:false});
});

win.add(list);
win.add(button);
win.open();

Comments

  1. Hans Knöchel 2014-07-12

    The bug i still present in the latest 3.3 build and prevents from releasing our app. Can someone look up this bug?
  2. Hans Knöchel 2014-08-03

    Found out, that the Bug only appears, when the section is already added to the listView before the items are applied to it. Simple test case to fix the given workaround:
       var ctr = 0;
        
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       var list = Ti.UI.createListView();
       var button = Ti.UI.createButton({
           title: 'click me'
       });
       button.addEventListener('click', function(e) {
       	var section = Ti.UI.createListSection();
           ctr++;
           var items = [];
           for (var i = 0; i < ctr; i++) {
               items.push({
                   properties: { title: ctr + ' rows' }
               });
           }
           section.setItems(items, {animated:false});
           list.setSections([section]);
       });
        
       win.add(list);
       win.add(button);
       win.open();
       
    But i would still say it is a bug, because the animationProperties should always be considered. :-)
  3. Vijay Singh 2016-11-07

    Now it is working properly . It looks , it is fixed in previous builds . It was reported long back .
  4. Lee Morris 2017-03-24

    Closing ticket as the issue cannot be reproduced and with reference to the previous comments.

JSON Source