Skip to content

TableView: contentOffset improvements #14075

@m1ga

Description

@m1ga

I have searched and made sure there are no existing issues for the issue I am filing

  • I have searched the existing issues

Description

The TableView contentOffset value is different on Android/iOS:

Android:
There are getters table.contentOffset.x and table.contentOffset.y but the value is returning a native height value (you have to divide it by ldi). The value in the scroll event is already in local space

iOS:
The getter is 0 and it only has the scroll event values.

Expected Behavior

Getter should be available on both platforms and it should return the same value as the scroll event contentOffset.

Actual behavior

Reproducible sample

var ldi = Ti.Platform.displayCaps.logicalDensityFactor;

var win = Ti.UI.createWindow();
var btn = Ti.UI.createButton({
	title: "click"
})
var tableData = [];
for (var i = 0; i < 100; ++i) {
	tableData.push({
		title: "Test" + i
	})
}

var table = Ti.UI.createTableView({
	data: tableData
});
win.add(table);
win.add(btn);
btn.addEventListener("click", function() {
	console.log("Current: " + table.contentOffset.x + " - " +table.contentOffset.y, "Fixed: " + Math.round(table.contentOffset.y/ldi));
})
table.addEventListener("scroll", function(e) {
	console.log(e.contentOffset.x, e.contentOffset.y);
})
win.open();

Steps to reproduce

Run the app, scroll the table and click the button. The normal contentOffset.y value should be the same in both cases.

Platform

Android & iOS

SDK version you are using

12.4.0

Alloy version you are using

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions