Skip to content

Instantly share code, notes, and snippets.

@alanleard
Created November 29, 2011 18:21
Show Gist options
  • Save alanleard/1405820 to your computer and use it in GitHub Desktop.
Save alanleard/1405820 to your computer and use it in GitHub Desktop.
Drag & Drop Blocks
var win = Titanium.UI.createWindow();
var item1 = Ti.UI.createView({
top:166,
left:180,
height:87,
width:60,
backgroundColor:'blue'
});
win.add(item1);
var item2 = Ti.UI.createImageView({
top:166,
left:80,
height:87,
width:100,
backgroundColor:'red'
});
win.add(item2);
var item3 = Ti.UI.createImageView({
top:100,
height:66,
width:160,
backgroundColor:'green'
});
win.add(item3);
item1.addEventListener('touchmove', function(e){
item1.center=e.globalPoint;
});
item2.addEventListener('touchmove', function(e){
item2.center=e.globalPoint;
});
item3.addEventListener('touchmove', function(e){
item3.center=e.globalPoint;
});
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment