Skip to content

Instantly share code, notes, and snippets.

@pec1985
Created July 24, 2012 21:27
Show Gist options
  • Save pec1985/3172773 to your computer and use it in GitHub Desktop.
Save pec1985/3172773 to your computer and use it in GitHub Desktop.
movable header
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