Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10425] MobileWeb: TableView scroll event has bad data

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2017-06-26T18:42:15.000+0000
Affected Version/sRelease 2.1.1
Fix Version/sn/a
ComponentsMobileWeb
Labelsparity
ReporterArthur Evans
AssigneeChris Barber
Created2012-08-13T13:38:36.000+0000
Updated2018-04-04T23:20:35.000+0000

Description

When trying to decode tableview scroll events using JSON.stringify, I am seeing some strange data. MobileWeb is producing the totalItemCount and visibileItemCount properties that Android generates, but totalItemCount is always 1 and visibleItemCount is always 0. The firstVisibleItem property is not included at all. Also, Mobile Web includes x and y properties with this event. These events were documented erroneously for the other platforms--neither Android nor iOS includes them. These appear to be the x,y coordinates of the user's touch, except that the y property appears to be inverted (i.e., distance from bottom instead of distance from top of view). Run the following code to test the events. Note that after a few cycles, this code crashes on mobile web as reported in the linked bug. Test code:

var win = Ti.UI.createWindow({
	backgroundColor: 'black',
	exitOnClose: true,
	fullscreen: false,
	title: 'TableView Demo'
});

var defaultFontSize = Ti.Platform.name === 'android' ? 16 : 14;
var tableData = [];

for (var i=1; i<=20; i++){
	var row = Ti.UI.createTableViewRow({
		className:'forumEvent',
		selectedBackgroundColor:'white',
		height:110,
		title:'Row ' + i
	});

	tableData.push(row);
}

var tableView = Ti.UI.createTableView({
	backgroundColor:'white',
	data:tableData
});
tableView.addEventListener('scroll', function(evt){
	Ti.API.info("Got event type[" + evt.type + "]: " + JSON.stringify(evt, function(key, value) {
		if(key === 'source' || key === 'type') {
			return undefined;
		} else {
			return value;
		}

	}, 2));});

win.add(tableView);
win.open();

Comments

  1. Bryan Hughes 2012-12-18

    Note: events cannot be JSON.stringified, hence the crash. I'm surprised it worked at all. The key/value pairs of interest need to be logged instead.
  2. Lee Morris 2017-06-26

    Marking ticket as "Won't Fix" as MobileWeb has been deprecated.
  3. Eric Merriman 2018-04-04

    Closing as will not fix.

JSON Source