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);
});

This entry was posted on 火曜日, 4月 9th, 2013 at 2:04 PM and is filed under Titanium. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。