Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-15848

iOS: Clearing listView doesn't work properly when use with scrollToItem(i,i,animation:false)

    Details

      Description

      When we use scrollToItem with animation:false in a listView,clear listView doesn't work properly.
      However, if use scrollToItem with 'animation:true', everything works fine.

      Steps To Reproduce :

      1. Create a new titanium classic project.

      2. Copy and paste the below code in app.js :

      var win = Ti.UI.createWindow({
      	backgroundColor : 'white'
      });
      var view = Ti.UI.createView({});
      var btn = Ti.UI.createButton({
      	top : 20,
      	backgroundColor : 'red',
      	width : 100,
      	title : 'Clear'
      });
       
      view.add(btn);
      win.add(view);
      var myTemplate = {
      	childTemplates : [{
      		type : 'Ti.UI.Label',
      		bindId : 'one',
      		properties : {
      			color : 'black',
      			font : {
      				fontFamily : 'Arial',
      				fontSize : '14dp'
      			},
      			left : '10dp'
      		}
      	}, {
      		type : 'Ti.UI.Label',
      		bindId : 'two',
      		properties : {
      			color : 'black',
      			font : {
      				fontFamily : 'Arial',
      				fontSize : '14dp'
      			},
      			left : '50dp'
      		}
      	}, {
      		type : 'Ti.UI.Label',
      		bindId : 'three',
      		properties : {
      			color : 'gray',
      			font : {
      				fontFamily : 'Arial',
      				fontSize : '14dp'
      			},
      			left : '90dp'
      		}
      	}, {
      		type : 'Ti.UI.Label',
      		bindId : 'four',
      		properties : {
      			color : 'gray',
      			font : {
      				fontFamily : 'Arial',
      				fontSize : '14dp'
      			},
      			left : '130dp'
      		}
      	}, {
      		type : 'Ti.UI.Label',
      		bindId : 'five',
      		properties : {
      			color : 'gray',
      			font : {
      				fontFamily : 'Arial',
      				fontSize : '14dp'
      			},
      			left : '170dp'
      		}
      	}, {
      		type : 'Ti.UI.Label',
      		bindId : 'six',
      		properties : {
      			color : 'gray',
      			font : {
      				fontFamily : 'Arial',
      				fontSize : '14dp'
      			},
      			left : '210dp'
      		}
      	}, {
      		type : 'Ti.UI.Label',
      		bindId : 'seven',
      		properties : {
      			color : 'gray',
      			font : {
      				fontFamily : 'Arial',
      				fontSize : '14dp'
      			},
      			left : '240dp'
      		}
      	}]
      };
       
      var genData = function(section) {
      	var data = [];
      	for ( i = 0; i < 20; i++) {
      		data.push({
      			one : {
      				text : section + ' one'
      			},
      			two : {
      				text : 'two'
      			},
      			three : {
      				text : 'three'
      			},
      			four : {
      				text : 'four'
      			},
      			five : {
      				text : 'five'
      			},
      			six : {
      				text : 'six'
      			},
      			seven : {
      				text : 'seven'
      			},
      			template : 'template'
      		});
      	}
       
      	return data;
      };
       
      var genSections = function() {
      	var sections = [];
      	for ( j = 0; j < 10; j++) {
      		var section = Ti.UI.createListSection({
      			headerTitle : 'Section ' + j
      		});
      		section.setItems(genData(j));
      		sections.push(section);
      	}
       
      	return sections;
      };
      var listView = Ti.UI.createListView({
      	top : 100
      });
      function populateEventsList() {
       
      	listView.templates = {
      		'template' : myTemplate
      	};
      	listView.setSections(genSections());
       
      }
       
      btn.addEventListener('click', function() {
       
      	var length = listView.sections.length;
      	if (length === 0) {
      		populateEventsList();
      		btn.title = 'Clear';
      		listView.scrollToItem(5, 3, {
      			animated : false,
       
      		});
      	} else {
      		listView.setSections([]);
      		btn.title = 'Populate';
      	}
       
      });
       
      populateEventsList();
      win.add(listView);
      win.open();
      

      2. Launch the application in iOS7 simulator/device.

      3. Click on 'Clear' button and you will see everything clears perfectly fine.

      4. Click on 'Populate' button and you will see everything populates as expected.

      5. Now again click on 'Clear' button, you will see listView doesn't cleared properly.

        Attachments

          Activity

            People

            • Assignee:
              vduggal Vishal Duggal (Inactive)
              Reporter:
              mpathak Meenakshi Pathak
            • Watchers:
              0 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-17937
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code