Created
April 27, 2014 12:31
-
-
Save nazrdogan/11344431 to your computer and use it in GitHub Desktop.
Drag and Drop Titanium Mobile
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({ | |
backgroundColor:'white' | |
}); | |
var circle = Titanium.UI.createView({ | |
height:200, | |
width:200, | |
backgroundColor:'#336699', | |
top:10, | |
left:50 | |
}); | |
Win.add(circle); | |
var circlePosition = { top: circle.top, left: circle.left }; | |
var xxx = 0; | |
var yyy = 0; | |
circle.addEventListener('touchstart', function(e) { | |
xxx = e.x; | |
yyy = e.y; | |
}); | |
circle.addEventListener('touchmove', function(e) { | |
circlePosition.top += e.y - yyy; | |
circlePosition.left += e.x - xxx; | |
Ti.API.info("Top-----"+circlePosition.top); | |
Ti.API.info("Left"+circlePosition.left); | |
circle.animate({ | |
top: circlePosition.top, | |
left: circlePosition.left, | |
duration: 1 | |
}); | |
}); | |
circle.addEventListener('touchend', function(e) { | |
xxx = 0; | |
yyy = 0; | |
}); | |
Win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment