titanium android swipe version 2
以前 touchstart , touchendで利用していたけど
https://github.com/appcelerator/titanium_mobile/pull/1835/files
修正されていた。
けどswipeを入れるとscrollが止まるという欠点が発生。
どうするか
ということで, androidのときは、swipeを使わないことにしました。
またtouchstart , touchendのところを少し修正。該当部分は以下になります。
iosのときは、swipeを利用しています。
Ti.API.info(‘android’)
self.x_start =0;
self.y_start =0;
self.addEventListener(‘touchstart’, function (e) {
self.x_start = e.x;
self.y_start = e.y;
});
self.addEventListener(‘touchend’, function (e) {
if( Math.pow((self.x_start-e.x),2) – Math.pow((self.y_start-e.y),2) > 100 ){
if (e.x > self.x_start) {
swipe({direction: ‘right’});
} else {
swipe({direction: ‘left’});
}
}
Ti.API.info(self.x_start);
Ti.API.info(self.y_start);
});
self.x_start =0;
self.y_start =0;
self.addEventListener(‘touchstart’, function (e) {
self.x_start = e.x;
self.y_start = e.y;
});
self.addEventListener(‘touchend’, function (e) {
if( Math.pow((self.x_start-e.x),2) – Math.pow((self.y_start-e.y),2) > 100 ){
if (e.x > self.x_start) {
swipe({direction: ‘right’});
} else {
swipe({direction: ‘left’});
}
}
Ti.API.info(self.x_start);
Ti.API.info(self.y_start);
});