Created
January 31, 2012 23:38
-
-
Save srahim/1713839 to your computer and use it in GitHub Desktop.
ScrollView GetcontentOFfset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); | |
Ti.API.info("Scrollview contentoffset object Type is : "+ scrollView.getContentOffset()); | |
Ti.API.info("the current contentoffset is x: "+ scrollView.contentOffset.x +" and y :" + scrollView.contentOffset.y); | |
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({x:1000,y:20},{animated:false}) ; | |
Ti.API.info("Scrollview contentoffset object Type is : "+ scrollView.getContentOffset()); | |
Ti.API.info("the current contentoffset is x: "+ scrollView.contentOffset.x +" and y :" + scrollView.contentOffset.y); | |
}); | |
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({x:1000,y:600},{animated:true}) ; | |
Ti.API.info("Scrollview contentoffset object Type is : "+ scrollView.getContentOffset()); | |
Ti.API.info("the current contentoffset is x: "+ scrollView.contentOffset.x +" and y :" + scrollView.contentOffset.y); | |
}); | |
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}) ; | |
Ti.API.info("Scrollview contentoffset object Type is : "+ scrollView.getContentOffset()); | |
Ti.API.info("the current contentoffset is x: "+ scrollView.contentOffset.x +"and y :" + scrollView.contentOffset.y); | |
}); | |
win.add(scrollView); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment