javascript - Tinder like function, appcelerator -


i tried re create tinder function.

i found code :

var win = titanium.ui.createwindow({     backgroundcolor: "#ffffff",     title: "win" });  // animations var animateleft = ti.ui.createanimation({     left: -520,     transform: ti.ui.create2dmatrix({rotate: 60}),     opacity: 0,     duration: 300 }); var animateright = ti.ui.createanimation({     left: 520,     transform: ti.ui.create2dmatrix({rotate: -60}),     opacity: 0,     duration: 300 });  var curx = 0;  win.addeventlistener('touchstart', function (e) {     curx = parseint(e.x, 10); });  win.addeventlistener('touchmove', function (e) {     if (!e.source.id || e.source.id !== 'oferta') {         return;     }      // subtracting current position starting horizontal position     var coordinates = parseint(e.x, 10) - curx;     // defining coordinates final left position      var matrix = ti.ui.create2dmatrix({rotate: -(coordinates / 10)});      var animate = ti.ui.createanimation({         left: coordinates,         transform: matrix,         duration: 20     });      e.source.animate(animate);      e.source.left = coordinates; });  win.addeventlistener('touchend', function (e) {     if (!e.source.id || e.source.id !== 'oferta') {         return;     }      // no longer moving window     if (e.source.left >= 75) {         e.source.animate(animateright);     } else if (e.source.left <= -75) {         e.source.animate(animateleft);     } else {         // repositioning window left         e.source.animate({             left: 0,             transform: ti.ui.create2dmatrix({rotate: 0}),             duration: 300         });     } });  (var = 0; < 10; i++) {      var wrap = ti.ui.createview({         "id": 'oferta',         "width": 320,         "height": 400,         "backgroundcolor": (i % 2 == 0 ? "red" : "blue")     });      var text = ti.ui.createlabel({         text: "row: " + i,         color: "black"     });      wrap.add(text);      win.add(wrap); }  win.open(); 

but there's weird behaviour. indeed, when took wrap view top, everythnig ok if put finger on bottom on wrap view, image becomes crazy..

try code , see strange behaviour.

i use titanium sdk 5.2.2 , ios 9.3.1 on iphone 6.

here s video showing weird thing: http://tinypic.com/player.php?v=x37d5u%3e&s=9#.vx_zdaolqb0

(sorry video size) help

use code convert pxtodp , vice versa:

put following code in lib folder , include require("measurement") instead of require("alloy/measurement")

var dpi = ti.platform.displaycaps.dpi, density = ti.platform.displaycaps.density;  exports.dptopx = function(val) {     switch (density) {       case "xxxhigh":         return 5 * val;        case "xxhigh":         return 4 * val;        case "xhigh":         return 3 * val;        case "high":         return 2 * val;        default:         return val;     } };  exports.pxtodp = function(val) {     switch (density) {       case "xxxhigh":         return 5 / val;        case "xxhigh":         return 4 / val;       case "xhigh":         return val / 3;        case "high":         return val / 2;        default:         return val;     } };  exports.pointpxtodp = function(pt) {     return {         x: exports.pxtodp(pt.x),         y: exports.pxtodp(pt.y)     }; }; 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -