Skip to content

Instantly share code, notes, and snippets.

@nuno
Last active April 24, 2016 14:39
Show Gist options
  • Save nuno/7e32f0b54e3d92d5c10efb5213677b0d to your computer and use it in GitHub Desktop.
Save nuno/7e32f0b54e3d92d5c10efb5213677b0d to your computer and use it in GitHub Desktop.
Test case scrollableView
/**
*
* 1 - Create a new alloy project and paste this code on index.file file.
*
* 2 - On index.xml file delete all code, and paste: <Alloy /> tag
*
* 3 - Run and test, and look at the dots of (showPagingControl) to see the creation time :)
*
*/
var win = Ti.UI.createWindow();
var view1 = Ti.UI.createView({
backgroundColor : '#123'
});
var view2 = Ti.UI.createView({
backgroundColor : '#246'
});
var view3 = Ti.UI.createView({
backgroundColor : '#48b'
});
// On creation load those 3 views
var scrollableView = Ti.UI.createScrollableView({
views : [view1, view2, view3],
showPagingControl : true
});
// add this view after 2 secs
setTimeout(function() {
scrollableView.addView(Ti.UI.createView({
backgroundColor : 'yellow'
}));
console.warn('Yellow view is added - should be added after the window is open');
}, 2000);
// add this view after 3 secs
setTimeout(function() {
scrollableView.addView(Ti.UI.createView({
backgroundColor : 'red'
}));
console.warn('red view is added - should be added after the window is open');
}, 3000);
win.add(scrollableView);
console.warn('The first 3 views added, ready to "Open Window"');
win.open();
console.warn('Open Window');
// add this view after 4 secs
setTimeout(function() {
scrollableView.addView(Ti.UI.createView({
backgroundColor : 'blue'
}));
console.warn('Blue view is added - should be added after the window is open');
}, 4000);
[WARN] : The first 3 views added, ready to "Open Window"
[WARN] : Open Window
[WARN] : Yellow view is added - should be added after the window is open
[WARN] : red view is added - should be added after the window is open
[WARN] : Blue view is added - should be added after the window is open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment