0

我正在尝试使用 Appcelerator 在 android 环境中拖动视图,结果显示动画非常跳跃。代码如下:

newmainwindow.addEventListener('touchstart', function(e){
    xPos = e.x;
    yPos = e.y;
});

newmainwindow.addEventListener('touchmove', function(e){

    var conPoint = newmainwindow.convertPointToView({x:e.x, y:e.y}, mainview);

    console.log("global y: " + conPoint.y);

    var moveY = conPoint.y - yPos;
    moveY /= 2;

    console.log("global diff y: " + moveY);

    newmainwindow.top = Math.abs(moveY);
});

newmainwindow.addEventListener('touchend', function(e){
    console.log("end");
});

我已经搜索了很多解决方案,但不幸的是它们都不起作用。任何帮助是极大的赞赏 :)

4

2 回答 2

1

Titanium 中可拖动视图的挑战在于 JS 和原生之间的桥梁成为瓶颈,因为所有的反馈都来回反馈。

Hyperloop(测试版)允许您直接使用平台 API。示例应用程序还包含用于拖动视图的示例:

https://github.com/appcelerator/hyperloop-examples

于 2016-02-04T13:06:35.407 回答
0

https://github.com/pec1985/TiDraggable

我使用了这个,它绝对是一个很棒的解决方案。开箱即用。

于 2016-02-03T15:05:11.127 回答