Titanium で Alloy MVC フレームワークを使用しており、ビュー間でスライドショーを作成したいと考えています。画面をスワイプすると、右から左または左から右へのスライド効果で次/前のビューを表示したい。私はこのコードを使用しています:
私の index.xml のタブ:
<Tab title="Bilan" icon="KS_nav_ui.png">
<Window title="Bilan" id="bilanTab" onSwipe="doBilanSwipe">
</Window>
</Tab>
動的に追加され、bilanTab 内に入力された質問ビュー:
<Alloy>
<Collection src="ReponsePossible">
<View id="questionContainer" class="container">
<Label id="questionText" />
<Button id="buttonNextQuestion">Question suivante</Button>
</View>
</Alloy>
そして、index.jsコントローラー内の私の2つの関数(prevQuestionがここに印刷されていない3つ):
var previousQuestion;
var nextQuestion;
function doBilanSwipe(e){
if (e.direction == 'left'){
nextQuestion();
}
else if (e.direction == 'right'){
prevQuestion();
}
}
function nextQuestion(){
if (questionsCurrentIndex < questions.length-1){
questionsCurrentIndex++;
$.previous = previousQuestion;
$.next = Alloy.createController('question', questions.at(questionsCurrentIndex));
nextQuestion = $.next;
$.next.questionContainer.left = 320;
$.bilanTab.add($.next.questionContainer);
$.next.questionContainer.animate({left:0, duration:200});
$.previous.questionContainer.animate({left:-320, duration:200},function(){
$.previous = previousQuestion;
$.next = nextQuestion;
$.bilanTab.remove($.previous.questionContainer);
previousQuestion = $.next;
$.previous.destroy();
});
}
}
私の問題は、最初のアニメーション (左に移動する最初のビュー) は問題ありませんが、その後、アニメーションなしで次のビューが表示されることです。
誰か助けてくれませんか?ありがとう!