[英]Polymer Neon-Animation: How to use cascaded-animation and hero-animation together?
我有一個使用一個小的應用cascaded-animation
和一個hero-animation
一起在這里 。
問題是我的主要元素設置為隱藏可見性,如官方文檔中的load
演示
<style>
:host {
display: block;
visibility: hidden;
}
</style>
index.html
偵聽WebComponentsReady
事件以在我的library-element
上調用show
函數:
<script>
document.addEventListener('WebComponentsReady', function () {
document.querySelector('library-element').show();
});
</script>
然后, show
方法使library-element visible
並調用動畫:
show: function () {
this.style.visibility = 'visible';
this.playAnimation('entry');
}
我現在遇到的問題是,我給一個具有兩個 entry
動畫的子元素設置了動畫,而show方法要播放該動畫。 cascaded-animation
和hero-animation
。
animationConfig: {
type: Object,
value: function () {
return {
'entry': [{
name: 'cascaded-animation',
animation: 'scale-up-animation',
}, {
name: 'hero-animation',
id: 'hero',
toPage: this
}],
'exit': [{
name: 'hero-animation',
id: 'hero',
fromPage: this
}, {
name: 'fade-out-animation',
node: this
}]
}
}
}
這會導致cascaded-animation
無法播放,因為hero-animation
會中斷,因為fromPage
hero-animation
所需的fromPage
。
這是我得到的警告:
英雄動畫:fromPage未定義!
這是我收到的錯誤消息:
polymer-mini.html:2061未捕獲的TypeError:在非對象上調用了CreateListFromArrayLike
結果是在啟動時, cascaded-animation
無法運行。
建議的解決方案:
一個:找到一種方法來修改index.html
的show
方法以僅播放第一個動畫。 也許是這樣的:
show: function () {
this.style.visibility = 'visible';
this.playAnimation(['entry'][0]);
}
第二:從第40行更改neon-shared-element-animation-behavior.html
:
if (!fromPage || !toPage) {
Polymer.Base._warn(this.is + ':', !fromPage ? 'fromPage' : 'toPage', 'is undefined!');
return null;
};
對此:
if (!fromPage || !toPage) {
console.warn(this.is + ':', !fromPage ? 'fromPage' : 'toPage', 'is undefined!');
return null;
};
到neon-animation
元素1.2.2的次要補丁之前的狀態。 這樣,至少它只會引發警告,而是播放動畫,而不是破壞動畫。
這是演示
隨意單擊任意紙卡,以觸發英雄和級聯動畫,並觀察到,每當刷新窗口時,級聯動畫都不會啟動。
如何與hero-animation
結合使用cascaded-animation
hero-animation
?
問題是一個錯誤,昨天通過霓虹動畫1.2.3版本進行了修補。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.