Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12887] TiAPI: Allow TableView to be scrolled BEFORE it is added to a view

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid, iOS
Labelsn/a
ReporterDavide Cassenti
AssigneeUnknown
Created2013-02-27T13:39:18.000+0000
Updated2018-02-28T20:03:43.000+0000

Description

Feature description

Before a TableView is added to a view, there is no way to scroll its content. The reason for doing this, is that (especially with complex tables), even setting the animation to false will show the beginning of the table before scrolling to the needed point. The use case is the follow: having an app such as a messaging app, which should start from the last message (bottom of the table) with the old ones already scrolled up.

How to see the issue

Use the following code. When you open the app on a device (Simualtor is fast enough not to show the problem, at least in my case), you can see the first rows for a while, and then the table scrolls to the end.
var win1 = Ti.UI.createWindow({
    backgroundColor: "#FFF"
});

var rows = [];

for (var i=0; i<100; i++) {
	var row = Ti.UI.createTableViewRow({
		className: 'test',
		height: 100,
		layout: 'horizontal'
	});

	var image = Ti.UI.createImageView({
		image: 'http://lorempixel.com/100/100?i=' + i
	});

	var text = Ti.UI.createLabel({
		text: 'Row ' + (i+1)
	});

	row.add(image);
	row.add(text);

	rows.push(row);
}

var table = Ti.UI.createTableView({
	data: rows
});


win1.add(table);
win1.open();

table.scrollToIndex(99, {
	animated: false
});

Workaround

The only workarond found is to set the opacity of the table to 0, then set it back to 1 after the table has scrolled (e.g. using setTimeout with a 10ms delay).

Comments

No comments

JSON Source