Javascript 如何在Android上通过Tianium SDK/Appcellerator正确使用touchmove

Javascript 如何在Android上通过Tianium SDK/Appcellerator正确使用touchmove,javascript,android,mobile,titanium,appcelerator,Javascript,Android,Mobile,Titanium,Appcelerator,我发现touchmove事件的行为方式似乎出乎我的意料。我似乎要处理多个坐标系。我通读了这张罚单:但似乎没有一个明确的解决办法 我尝试了Vishal Duggal提出的使用convertPointToView的建议,但在某些情况下,它似乎有效,但在其他情况下,它似乎会把事情搞得更糟。有时convertPointToView返回null,即使没有从视图层次结构中删除任何my元素。每个元素都有自己的坐标系吗?我看了这个文档:,但它似乎没有解释坐标系是如何工作的 有时convertPointToVie

我发现touchmove事件的行为方式似乎出乎我的意料。我似乎要处理多个坐标系。我通读了这张罚单:但似乎没有一个明确的解决办法

我尝试了Vishal Duggal提出的使用convertPointToView的建议,但在某些情况下,它似乎有效,但在其他情况下,它似乎会把事情搞得更糟。有时convertPointToView返回null,即使没有从视图层次结构中删除任何my元素。每个元素都有自己的坐标系吗?我看了这个文档:,但它似乎没有解释坐标系是如何工作的

有时convertPointToView似乎也返回不正确的值。将我从e.x获得的值与从convertPointToView获得的值进行比较,当e.x似乎具有正确的值时,它似乎有时会跳到一个较高的值

有人有什么好的推荐信吗?我能读到吗


我的基本问题是:使用触摸事件的最佳实践是什么?最重要的是,如何确保我从触摸事件对象获得的坐标继续有意义,即使我正在触摸的对象正在移动(响应触摸)?

检查我编写的这个示例,以测试如何将convertPointToView用于触摸移动事件。


hth

检查我编写的这个示例,以测试如何将convertPointToView与触摸移动事件结合使用。


hth

它不处理触摸源对象的移动,但它帮助我处理从错误对象收听时接收到的奇怪坐标。它不处理触摸源对象的移动,但它帮助我处理从错误对象收听时接收到的奇怪坐标。
try this code

var circle = Ti.UI.createView({
height:300,
backgroundColor: 'red',
width:250
});
$.win.add(circle);

var item1 = Ti.UI.createImageView({
top:'0',
id:'item1',
//left:'0',
width:'50',
height:'50',
zIndex:'1',
backgroundColor:'green',
image:'/burger_menu.png'
});
circle.add(item1);

var wth = item1.getWidth()/2;
var hgt = item1.getHeight()/2;

item1.addEventListener('touchmove', function(e) {
touchMove(item1 , e);

});

function touchMove(obj , e)
{

var convertedPoint = obj.convertPointToView({x: e.x, y: e.y}, circle);

    if(convertedPoint != null)
    {
                item1.animate({
                left: Math.round(convertedPoint.x/Ti.Platform.displayCaps.logicalDensityFactor) - wth,  
                top: Math.round(convertedPoint.y/Ti.Platform.displayCaps.logicalDensityFactor) - hgt ,
                duration: 1 
                   });      
    }
}

$.win.open();