2014-12-02 139 views
1

我可以在離子框架視圖中創建簡單的動畫。動畫將是非常簡單的動畫,比如改變顏色,褪色,增加元素的高度和寬度,就像jquery在網頁中做的動畫一樣。離子框架中的簡單動畫

回答

0

是的。離子中沒有任何東西會阻止這一點。你真的嘗試過嗎?或者你問是否Ionic 運送這樣的東西?據我所知,答案是否定的。

+0

我不知道我將如何去關於嘗試此。通常情況下,我會在jQuery中做這些事情,但我在哪裏寫離子jquery! – 2014-12-02 22:19:55

1

離子動畫與您在標準html頁面上的動畫一樣,唯一的區別是如何設置它的角度。

它在分配給視圖的控制器中,您可以添加您的代碼。

.controller('homeCtrl', ['$scope', function($scope) { 
    // Jquery animation 
    $(selector).animate({params},speed,callback); 

    // Greensock animation 
    var photo = document.getElementById("photo"); //or use jQuery's $("#photo") 
    TweenLite.to(photo, 1.5, {width:100}); 

    // or define a function and call it when you want an animation to run 
    $scope.animate = function(element) { 
     $(element).animate({params},speed,callback); 
    } 
}]) 

這就是它的要點,你可以看看更詳細的東西上YearOfMoo

+0

那麼你是否提供了添加Greensock或jQuery以及Ionic Framework的建議?這是否複製了已經嵌入到Ionic Framework中的用於處理動畫的代碼?將動畫操作和觸發器添加到指令而不是控制器中是不是更好的做法? – BrightIntelDusk 2015-01-27 20:25:43

+0

我不推薦任何事情,除了我當時解決我的問題,並且它對我來說非常出色:) Ionic沒有Greensock提供的動畫功能,但Moo年顯示如何將它整合到角度中它非常適合我的項目。 – CaptRisky 2015-02-01 13:30:21

2

是的,你可以對這個看看。

一個功能強大的JavaScript動畫引擎,適用於web和混合移動應用程序,受Facebook Pop的啓發,由Ionic團隊構建。

https://github.com/driftyco/collide

var animation = collide.animation({ 
    // 'linear|ease|ease-in|ease-out|ease-in-out|cubic-bezer(x1,y1,x2,y2)', 
    // or function(t, duration), 
    // or a dynamics configuration (see below) 
    easing: 'ease-in-out', 
    duration: 1000, 
    percent: 0, 
    reverse: false 
}); 

// Actions, all of these return `this` and are chainable 
// .on('step' callback is given a 'percent', 0-1, as argument (for springs it could be outside 0-1 range) 
// .on('stop' callback is given a boolean, wasCompleted 
animation.on(/step|destroy|start|stop|complete/, function() {}) 
animation.once(...) //same event types 
animation.off(...) //works like jquery.off 
animation.stop(); //stop/pause at current position 
animation.start(shouldSetImmediately); //start from current position 
animation.restart(); 
animation.velocity(n) //starts the animation going at the given velocity ,relative to the distance, decaying 
animation.distance(n); //distance for the velocity to be relative to 
animation.destroy(); //unbind all events & deallocate 

animation.isRunning(); //boolean getter 

//These are getters and setters. 
//No arguments is a getter, argument is a chainable setter. 
animation.percent(newPercent, shouldSetImmediately); //0-1 
animation.duration(duration); //milliseconds 
animation.reverse(isReverse); 

animation.easing(easing); //setter, string|function(t,duration)|dynamicsConfiguration. 
// Dynamics configuration looks like this one of these: 
// animation.easing({ 
// type: 'spring', 
// frequency: 15, 
// friction: 200, 
// initialForce: false 
// }); 
// animation.easing({ 
// type: 'gravity', 
// bounce: 40, 
// gravity: 1000, 
// }); 
+0

你知道我在哪裏可以找到這個API在Ionic App中使用的例子嗎?這個代碼是否會添加到指令中? – BrightIntelDusk 2015-01-27 20:26:19

+0

在回購中給出了一個示例,請參閱* test.html *:https://github.com/driftyco/collide/blob/master/test.html – AAhad 2015-01-28 05:07:48