小编kra*_*kax的帖子

Appcelerator合金视图滑动

我在Titanium上使用Alloy MVC框架,并希望在视图之间进行幻灯片放映.当我在屏幕上滑动时,我想显示下一个/上一个视图,其中包含从右到左或从左到右的滑动效果.我正在使用此代码:

我的index.xml中的一个标签:

<Tab title="Bilan" icon="KS_nav_ui.png">
    <Window title="Bilan" id="bilanTab" onSwipe="doBilanSwipe">
    </Window>
</Tab>
Run Code Online (Sandbox Code Playgroud)

在bilanTab中动态添加和填充问题视图:

<Alloy>
<Collection src="ReponsePossible">
<View id="questionContainer" class="container">
    <Label id="questionText" />
    <Button id="buttonNextQuestion">Question suivante</Button>
</View>
</Alloy>
Run Code Online (Sandbox Code Playgroud)

和index.js控制器里面的两个函数(在这里没有打印出来的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); …
Run Code Online (Sandbox Code Playgroud)

animation view titanium appcelerator titanium-alloy

1
推荐指数
1
解决办法
4707
查看次数

标签 统计

animation ×1

appcelerator ×1

titanium ×1

titanium-alloy ×1

view ×1