我正在尝试使用 Appcelerator Titanium 获取 View 中 ImageView 的相对位置。
我的代码:
var contentView = Ti.UI.createView({width:300,height:300,backgroundColor:"red"});
var imgView = Ti.UI.createImageView({image:'image.png', height:100, width:100, zIndex:5});
contentView.add(imgView);
win.add(contentView);
我想知道在 touchmove 事件期间 imgView 在 contentView 中的位置:
var olt = Ti.UI.create3DMatrix(), curX, curY;
imgView.addEventListener('touchstart', function(e) {
curX = e.x;
curY = e.y;
});
imgView.addEventListener('touchmove', function(e) {
var deltaX = e.x - curX;
var deltaY = e.y - curY;
olt = olt.translate(deltaX, deltaY, 0);
imgView.animate({transform:olt, duration:100});
//-- top/left position of the imgView ?
});
请问您有什么想法吗?谢谢:)
最佳答案
imgView.rect.x
imgView.rect.y
这对你有用吗? View 对象的属性位于 http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.View
关于javascript - 获取 Appcelerator Titanium 中 View 的相对位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36730474/