0
雖然嘗試基於帶有AngularJS $ animate的velocity.js構建動畫,但遇到了一個我幾個小時都無法找到的小問題,雖然解決方案非常簡單。爲避免你同樣的困難,我向你們介紹我的解決方案:使用第三方JavaScript庫自定義AngularJS動畫
考慮下面的代碼:
app.directive("animate", function ($animate, $timeout) {
return function (scope, element, attrs) {
element.on('click', function() {
// to fire $animate, need to wrap it into a $timeout wrapper.
$timeout(function() {
$animate.addClass(element, 'test').then(function() {
$timeout(function() {
$animate.removeClass(element, 'test');
}, 0);
});
}, attrs.delay || 0);
});
};
});
只是想說明我標記爲「主持人」的關注。我認爲這對於某個人來說可能是有價值的,但是需要在問題和答案方面進行重新表述,而不是全部在問題部分。 – Josh 2014-12-09 13:37:52
Thx爲旗!在那裏的第一篇文章,所以很無知的最佳做法:) – grebett 2014-12-09 15:12:55
我只是不希望人們進來關閉它。這些信息是有價值的,但只是需要打破。我不認爲只有版主纔可以這樣做...... – Josh 2014-12-09 16:15:39