当 touchmove 事件发生时,我试图在 Titanium iPhone 应用程序中获取 globalPoint,我使用以下代码获取 globalPoint
var x = parseInt(e.globalPoint.x, 10);
在我将 Titanium 3.0.2 GA 更新到 3.1.0 GA 之前它工作正常,更新后我运行应用程序出现以下错误
“未定义”不是对象(评估“e.globalPoint.x”)
我正在使用此代码来滑动窗口
var animateLeft = Ti.UI.createAnimation({
left : 250,
curve : Ti.UI.ANIMATION_CURVE_EASE_OUT,
duration : 150
});
var animateRight = Ti.UI.createAnimation({
left : 0,
curve : Ti.UI.ANIMATION_CURVE_EASE_OUT,
duration : 150
});
var touchStartX = 0;
var touchStarted = false;
$.innerwin.addEventListener('touchstart', function(e) {
touchStartX = parseInt(e.x, 10);
});
$.innerwin.addEventListener('touchend', function(e) {
touchStarted = false;
if ($.win.left >= 150) {
$.win.animate(animateLeft);
hasSlided = true;
} else {
$.win.animate(animateRight);
hasSlided = false;
}
});
$.innerwin.addEventListener('touchmove', function(e) {
var x = parseInt(e.globalPoint.x, 10);
var newLeft = x - touchStartX;
if (touchStarted) {
if (newLeft <= 250 && newLeft >= 0) {
$.win.left = newLeft;
}
}
if (newLeft > 30) {
touchStarted = true;
}
});
$.button.addEventListener('singletap', function(e) {
$.toggleSlider();
});
var hasSlided = false;
exports.toggleSlider = function() {
if (!hasSlided) {
$.win.animate(animateLeft);
hasSlided = true;
} else {
$.win.animate(animateRight);
hasSlided = false;
}
}