0

내 애플 리케이션 내에서 verticaly 세로보기를 드래그하려면 아래 내 코드입니다. ID가 "win"이고 정사각형 모양의 창 (100x100)이있는 창이 있습니다. 티타늄 appcelerator 드래그보기

var window = $.win; 
var lastTouchPosition = 0; 
$.demo.addEventListener("touchstart", function(e){ 
    var touchPos = {x:e.x, y:e.y}; 
     lastTouchPosition = $.demo.convertPointToView(touchPos, window); 
}); 

$.demo.addEventListener("touchmove", function(e){ 
    var touchPos = {x:e.x, y:e.y}; 
    var newTouchPosition = $.demo.convertPointToView(touchPos, window); 

    $.demo.top += Number(newTouchPosition.y) - Number(lastTouchPosition.y); 
    $.demo.left += Number(newTouchPosition.x) - Number(lastTouchPosition.y); 
    //lastTouchPosition = newTouchPosition; 

}); 

나는 다음과 같은 얻을 뷰를 끌어 시작

는 WARN : [WARN] : 요청 잘못된 치수 값 (유모). 치수를 정의하지 않고 대신 지정하십시오. 내 의견이 움직이지 않습니다. 아이디어를 줄 수있는 방법을 알려주세요. 특정 수직 위치 값 (예 : 뷰포트의 하단)에 도달하면 뷰를 드래그하여 멈추게 할 수 있습니다.

감사합니다.

답변

0

내가 대신 다음과 같이 윈도우/컨테이너보기로 터치 이벤트를 추가 :

var WIDTH = (OS_ANDROID) ? Ti.Platform.displayCaps.platformWidth/dpi : Ti.Platform.displayCaps.platformWidth; 
var HEIGHT = (OS_ANDROID) ? Ti.Platform.displayCaps.platformHeight/dpi : Ti.Platform.displayCaps.platformHeight; 
var sx = 0; 
var sy = 0; 
var cx = 0; 
var cy = 0; 
var xDistance = 0; 

function onTouchStart(e) { 
    // start movement 
    sx = e.x; 
    sy = e.y; 
    cx = e.x; 
    cy = e.y; 
} 

function onTouchMove(e) { 
    xDistance = cx - sx; 
    var yDistance = cy - sy; 

    var rotationStrength = Math.min(xDistance/(WIDTH), 1); 
    var rotationStrengthY = Math.min(yDistance/(HEIGHT), 1); 

    var rotationAngel = (2 * Math.PI * rotationStrength/16); 
    var scaleStrength = 1 - Math.abs(rotationStrength)/16; 
    var scaleStrengthY = 1 - Math.abs(rotationStrengthY)/16; 

    var scaleMax = Math.min(scaleStrength, scaleStrengthY); 
    var scale = Math.max(scaleMax, 0.93); 

    $.view_card_front.rotation = rotationAngel * 20; 
    $.view_card_front.translationX = xDistance; 
    $.view_card_front.setTranslationY(yDistance); 
    $.view_card_front.scaleX = scale; 
    $.view_card_front.scaleY = scale; 

    cx = e.x; 
    cy = e.y; 
} 

function onTouchEnd(e) { 
    // check xDistance 
} 

$.index.addEventListener("touchmove", onTouchMove); 
$.index.addEventListener("touchstart", onTouchStart); 
$.index.addEventListener("touchend", onTouchEnd); 

XML에서 touchEnabled:false

이것은 (당신에게 좋은 부드러운 movent을 줄 것이다 <View id="view_card_front"/>에있다 이 예에서 회전)

+0

감사합니다 miga 내가 이것을 시도합니다 – Rahajason

+0

Juste 한 가지 질문은 왜 놓았습니까? (HEIGHT) 및 (WIDTH), 어떤 변수에 해당합니까? – Rahajason

+0

죄송합니다. 추가했습니다. 그것은 (내 경우에는) 디스플레이 너비와 높이 – miga