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

Android: ScrollView - Runtime error generated when scrollView.contentOffset object is used in a call back function

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 1.8.0.1, Release 1.8.1
    • Component/s: Android
    • Environment:

      SDK build: 1.8.0.1, 1.8.1.v20120124200134
      Runtime: v8, rhino
      OS: Mac OS X Lion (10.7.2)
      Titanium Studio, build: 1.0.8.201201210622
      Device: Nook Color (2.2)

      Description

      Steps to reproduce:
      1. Launch the following code in app.js:

      app.js

      var win = Titanium.UI.createWindow({  
          layout:'vertical',
          backgroundColor:'#fff'
      });
       
      var scrollView = Ti.UI.createScrollView({
      	showHorizontalScrollIndicator:true, showVerticalScrollIndicator:true,
      	width: 250, height: 100, top: 50,
      	borderColor:'green', borderWidth:1,
      	contentWidth:1000, contentHeight:100
      });
       
      for(var i=0; i<10; i++) {
      	for(var j=0; j<10; j++) {
      		scrollView.add(Ti.UI.createLabel({
      			top:i*100, left:j*100,
      			width:100, height:100,
      			text:i+':'+j, textAlign:'center',
      			color:'white',
      			backgroundColor:'#A0' + Number(i%2*8).toString(16) +'0'+ Number(8-j%2*8).toString(16)+'0',
      			borderColor:'black', borderWidth:1 
      		}));
      	}
      }
       
      var button = Ti.UI.createButton({title:'Flip', width:100, height:50});
      button.addEventListener('click', function() {
      	scrollView.width = 100;
      	scrollView.height = 250;
      	
      	scrollView.contentWidth = 100;
      	scrollView.contentHeight = 1000;
       
      	button.title = 'Click again';
      	
      });
       
      scrollView.addEventListener('scroll', function() {
              // bug is here 
      	Ti.API.info('Offset: (' + scrollView.contentOffset.x + ', ' + scrollView.contentOffset.y + ')');
      });
      win.add(scrollView);
      win.add(button);
      win.open();
      

      Actual: Runtime error occur. See attachment.
      Expected: Should not get a runtime error. Above code ran without error in iOS

      Note: Occurs in 1.8.0.1

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hpham Hieu Pham
                Reporter:
                wluu Wilson Luu (Inactive)
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Integration