Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15999] Android: Disable scrollToItem animation on ListView

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-04-17T21:29:24.000+0000
Affected Version/sRelease 3.1.1, Release 3.1.2, Release 3.1.3
Fix Version/s2014 Sprint 08, 2014 Sprint 08 SDK, Release 3.3.0
ComponentsAndroid
Labelslistview, module_listview, qe-testadded, scrollToItem, supportTeam, triage
ReporterMarco Cota
AssigneeVishal Duggal
Created2013-12-16T14:24:45.000+0000
Updated2014-04-22T21:23:30.000+0000

Description

Request

In the Android listView allow user to disable animation on the scrollToItem method or set selection to a specific Section and row.

Current Behavior

The listView element is able to disable animation on scrollToItem and set selection only on iOS.

Sample Code


$.listView.scrollToItem(10, 1, {
            animated: false
});

Comments

  1. Moshe Marciano 2013-12-16

    also, controlling the speed of the animation is a nice, or making it adaptive to the distance it needs to pass when it scrolls from row A to row B... slower animation when we need to move 5, 10, 20 rows, and much faster when we need to move 200,300 rows..
  2. Vishal Duggal 2014-04-17

    Test Case
       var win = Ti.UI.createWindow({
       	backgroundColor:'white',
       	exitOnClose:true,
       	title:'ScrollToItem',
       	layout:'vertical'
       });
       
       var container = Ti.UI.createView({height:Ti.UI.SIZE});
       win.add(container);
       
       var b1 = Ti.UI.createButton({
       	left:'2%',
       	top:0,
       	backgroundColor:'black',
       	color:'white',
       	title:'animated=true',
       	width:'45%'
       });
       
       var b2 = Ti.UI.createButton({
       	right:'2%',
       	top:0,
       	backgroundColor:'black',
       	color:'white',
       	title:'animated=false',
       	width:'45%'
       });
       
       container.add(b1);
       container.add(b2);
       
       var label = Ti.UI.createLabel({color:'black',height:'64dp',font:{fontSize:'14dp'}});
       win.add(label);
       
       
       function genSection(section)
       {
       	var data = [];
       	for(i=0;i<25;i++) {
       		data.push({properties: { title: 'SectionIndex '+section+' ItemIndex '+i}});
       	}
       
       	var section = Ti.UI.createListSection({items:data,headerTitle:'Section '+section});
       	return section;
       }
       
       var sections = [];
       for(j=0;j<25;j++) {
       	sections.push(genSection(j));
       }
       
       var listView = Ti.UI.createListView({
       	sections:sections
       });
       
       win.add(listView);
       win.open();
       
       function scrollToRandom(animated)
       {
       	var sIndex = Math.floor(Math.random()*31)%25;
       	var iIndex = Math.floor(Math.random()*83)%25;
       	label.text = 'listView.scrollToItem('+sIndex+','+iIndex+',{animated:'+animated+'})';
       	listView.scrollToItem(sIndex,iIndex,{animated:animated});
       }
       
       b1.addEventListener('click',function(){
       	scrollToRandom(true);
       });
       b2.addEventListener('click',function(){
       	scrollToRandom(false);
       });
       
  3. Vishal Duggal 2014-04-17

    Pull pending against master https://github.com/appcelerator/titanium_mobile/pull/5620

JSON Source