簡體   English   中英

Polymer Neon-Animation:如何同時使用級聯動畫和英雄動畫?

[英]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-animationhero-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.htmlshow方法以僅播放第一個動畫。 也許是這樣的:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM