Created
July 24, 2012 21:27
-
-
Save pec1985/3172773 to your computer and use it in GitHub Desktop.
movable header
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(); | |
// image found at | |
// http://f.cl.ly/items/3F2Z0j112l3r0x2Z0215/background.png | |
var bgImage = Ti.UI.createImageView({ | |
width:320, | |
height:320, | |
image: 'background.png', | |
top:-100 | |
}); | |
var headerView = Ti.UI.createView({ | |
height: 100, | |
backgroundColor: 'transparent' | |
}); | |
win.add(bgImage); | |
var table = Ti.UI.createTableView({ | |
headerView:headerView, | |
backgroundColor:'transparent', | |
data: [ | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'}, | |
{title: 'Hello World', backgroundColor: 'white'} | |
] | |
}); | |
win.add(table); | |
win.open(); | |
table.addEventListener('scroll', function(e){ | |
var offsetY = e.contentOffset.y; | |
var top = -120; | |
if(offsetY < 0){ | |
top -= offsetY / 2; | |
} else { | |
top -= offsetY; | |
} | |
bgImage.top = top; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment