Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(android): append ListView events while scrolling #13958

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Dec 30, 2023

Before this PR the template events only worked for visible items. Items that were generated during scrolling didn't have the events.

Test

var win = Ti.UI.createWindow({
	backgroundColor: 'white'
});


function playout() {
	console.log("Post")
	this.removeEventListener("postlayout", playout);
	this.animate({
		opacity: 1,
		duration: 150,
		curve: Titanium.UI.ANIMATION_CURVE_EASE_IN
	});
}

var myTemplate = {
	events: {
		postlayout: playout
	},
	properties: {
		height: 100,
		opacity: 0.1
	},
	childTemplates: [{
			type: 'Ti.UI.Label',
			bindId: 'info',
			properties: {
				color: 'black',
				font: {
					fontFamily: 'Arial',
					fontSize: '20dp',
					fontWeight: 'bold'
				},
				left: '60dp',
				top: 0,
			}
		},
		{
			type: 'Ti.UI.Label',
			bindId: 'es_info',
			properties: {
				color: 'gray',
				font: {
					fontFamily: 'Arial',
					fontSize: '14dp'
				},
				left: '60dp',
				top: '25dp',
			}
		}
	]
};

var listView = Ti.UI.createListView({

	templates: {
		'template': myTemplate
	},
	defaultItemTemplate: 'template'
});
var sections = [];

var fruitDataSet = [
	{
		info: {
			text: 'Apple'
		},
		es_info: {
			text: 'Manzana'
		}
	},
	{
		info: {
			text: 'Banana'
		},
		es_info: {
			text: 'Banana'
		}
	}
];
var fruitSection = Ti.UI.createListSection({
	headerTitle: 'Fruits / Frutas',
	items: fruitDataSet
});
sections.push(fruitSection);

var vegDataSet = [{
		info: {
			text: 'Carrot'
		},
		es_info: {
			text: 'Zanahoria'
		}
	},
	{
		info: {
			text: 'Potato'
		},
		es_info: {
			text: 'Patata'
		}
	}
];
var vegSection = Ti.UI.createListSection({
	headerTitle: 'Vegetables / Verduras',
	items: vegDataSet
});
sections.push(vegSection);
var grainDataSet = [];
for (var i = 0; i < 100; ++i) {
	grainDataSet.push({
		info: {
			text: 'Corn'
		},
		es_info: {
			text: 'Maiz'
		},
		pic: {
			image: 'corn.png'
		}
	}, {
		info: {
			text: 'Rice'
		},
		es_info: {
			text: 'Arroz'
		}
	});
}
var grainSection = Ti.UI.createListSection({
	headerTitle: 'Grains / Granos',
	items: grainDataSet
});
sections.push(grainSection);

listView.sections = sections;
win.add(listView);
win.open();
  • run the code
  • scroll and see if the elements fade in

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant