Open m1ga opened 11 months ago
Before this PR the template events only worked for visible items. Items that were generated during scrolling didn't have the events.
events
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();
Before this PR the template
events
only worked for visible items. Items that were generated during scrolling didn't have the events.Test