Last active
December 11, 2015 06:08
-
-
Save lcruz/4556754 to your computer and use it in GitHub Desktop.
Ejemplo de scrollview y scrolleableView en Appcelerator SDK 3.0 (sin conflictos)
This file contains 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 = Ti.UI.createWindow(); | |
// Vistas de ejemplo | |
var view0 = Ti.UI.createView({ width: Ti.UI.FILL, height: 150, backgroundColor: 'red' }); | |
var view1 = Ti.UI.createView({ width: Ti.UI.FILL, height: 150, backgroundColor: 'brown' }); | |
var view2 = Ti.UI.createView({ width: Ti.UI.FILL, height: 150, backgroundColor: 'silver' }); | |
var view3 = Ti.UI.createView({ width: Ti.UI.FILL, height: 200, backgroundColor: 'blue' }); | |
var view4 = Ti.UI.createView({ width: Ti.UI.FILL, height: 200, backgroundColor: 'yellow' }); | |
var view5 = Ti.UI.createView({ width: Ti.UI.FILL, height: 200, backgroundColor: 'green' }); | |
var view6 = Ti.UI.createView({ width: Ti.UI.FILL, height: 200, backgroundColor: 'magenta' }); | |
var scrollView = Ti.UI.createScrollView({ | |
contentWidth: 'auto', | |
contentHeight: 'auto', | |
showVerticalScrollIndicator: true, | |
showHorizontalScrollIndicator: true, | |
height: Ti.UI.FILL, | |
width: Ti.UI.FILL, | |
backgroundColor: 'white', | |
layout: 'vertical', | |
scrollType: 'vertical' | |
}); | |
var listView = [view0,view1,view2]; | |
var scrollableView = Ti.UI.createScrollableView({ | |
views:listView, | |
currentPage: 0, | |
height: Ti.UI.FILL, | |
width: Ti.UI.FILL, | |
top: 0 | |
}); | |
var timer = null; | |
// ----- SOLUCION ------ | |
/* Este es el scroll interno */ | |
scrollableView.addEventListener("scroll", function(e) { | |
scrollView.setScrollingEnabled(false); | |
// Si ya se inicio el timer lo limpiamos | |
if (timer != null) { | |
clearTimeout(timer); | |
} | |
// Iniciamos el timer, el scroll se activara luego de X millisegundos | |
timer = setTimeout(function() { | |
scrollView.setScrollingEnabled(true); | |
}, 200); | |
}); | |
// --------------------- | |
scrollView.add(scrollableView); | |
scrollView.add(view3); | |
scrollView.add(view4); | |
scrollView.add(view5); | |
scrollView.add(view6); | |
win.add(scrollView); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment