Skip to content

Instantly share code, notes, and snippets.

@srahim
Created January 13, 2012 22:42
Show Gist options
  • Save srahim/1609171 to your computer and use it in GitHub Desktop.
Save srahim/1609171 to your computer and use it in GitHub Desktop.
testing for scrollview contentoffset
var win = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
});
var scrollView = Titanium.UI.createScrollView({
contentWidth:'auto',
contentHeight:'auto',
top:0,
showVerticalScrollIndicator:true,
showHorizontalScrollIndicator:true
});
var view = Ti.UI.createView({
backgroundColor:'#336699',
borderRadius:10,
width:3000,
height:700,
top:10
});
scrollView.add(view);
var button = Titanium.UI.createButton({
title:'ContOffset W/O Anim.',
height:40,
width:200,
top:10,
left:10
});
view.add(button);
button.addEventListener('click', function()
{
scrollView.setContentOffset({value:{x:1000,y:20},animated:false}) ;
});
var button1 = Titanium.UI.createButton({
title:'ContOffsetwith Animtn',
height:40,
width:200,
top:50,
left:1000
});
view.add(button1);
button1.addEventListener('click', function()
{
scrollView.setContentOffset({value:{x:1000,y:600},animated:true}) ;
});
var button2 = Titanium.UI.createButton({
title:'Normal ContentOffset',
height:40,
width:200,
top:600,
left:1000
});
view.add(button2);
button2.addEventListener('click', function()
{
scrollView.setContentOffset({x:10.0,y:10.0}) ;
});
win.add(scrollView);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment