question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Animation error when using *ngIf on animation element

See original GitHub issue

From @Plamen5kov on November 14, 2016 11:55

From @MaklaCof on November 11, 2016 21:38

I get error when variable in *ngIf is changed:

> [JS      ] EXCEPTION: Uncaught (in promise): Error: Animation cancelled.
[JS      ] ORIGINAL STACKTRACE:
[JS      ] Error: Uncaught (in promise): Error: Animation cancelled.
[JS      ]     at resolvePromise (/data/data/com.telerik.Mobile/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:416:31)
[JS      ]     at resolvePromise (/data/data/com.telerik.Mobile/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:401:17)
[JS      ]     at /data/data/com.telerik.Mobile/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:449:17
[JS      ]     at ZoneDelegate.invokeTask (/data/data/com.telerik.Mobile/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:223:37)
[JS      ]     at Object.NgZoneImpl.inner.inner.fork.onInvokeTask (/data/data/com.telerik.Mobile/files/app/tns_modules/@angular/core/bundles/core.umd.js:6233:41)
[JS      ]     at ZoneDelegate.invokeTask (/data/data/com.telerik.Mobile/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:222:42)
[JS      ]     at Zone.runTask (/data/data/com.telerik.Mobile/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:123:47)
[JS      ]     at drainMicroTaskQueue (/data/data/com.telerik.Mobile/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:355:35)
[JS      ] Unhandled Promise rejection: Animation cancelled. ; Zone: angular ; Task: Promise.then ; Value: Error: Animation cancelled. Error: Animation cancelled.
[JS      ]     at Animation._rejectAnimationFinishedPromise (/data/data/com.telerik.Mobile/files/app/tns_modules/ui/animation/animation-common.js:110:22)
[JS      ]     at Animation._onAndroidAnimationCancel (/data/data/com.telerik.Mobile/files/app/tns_modules/ui/animation/animation.js:113:14)
[JS      ]     at Animation._animatorListener.android.animation.Animator.AnimatorListener.onAnimationCancel (/data/data/com.telerik.Mobile/files/app/tns_modules/ui/animation/animation.js:53:22)
[JS      ]     at Animation.cancel (/data/data/com.telerik.Mobile/files/app/tns_modules/ui/animation/animation.js:92:27)
[JS      ]     at KeyframeAnimation.cancel (/data/data/com.telerik.Mobile/files/app/tns_modules/ui/animation/keyframe-animation.js:105:31)
[JS      ]     at Label.View._unregisterAllAnimations (/data/data/com.telerik.Mobile/files/app/tns_modules/ui/core/view-common.js:1114:27)
[JS      ]     at Style._resetCssValues (/data/data/com.telerik.Mobile/files/app/tns_modules/ui/styling/style.js:925:20)
[JS      ]     at CssState.apply (/data/data/com.telerik.Mobile/files/app/tns_modules/ui/styling/style-scope.js:46:25)
[JS      ]     at Label.View.applyCssState (/data/data/com.telerik.Mobile/files/app/tns_modules/ui/core/view-common.js:1201:24)
[JS      ]     at Label.View._onCssStateChange (/data/data/com.telerik.Mobile/files/app/tns_modules/ui/core/view-common.js:1194:14)
[JS      ] Error: Uncaught (in promise): Error: Animation cancelled.

HTML:

<Label class="fa fa-spin" text="&#xf013;" *ngIf="isRunning"></Label>

CSS:

`.fa {
    font-family: FontAwesome;
    font-size: 24;
}

.fa-spin {
    animation-name: fa-spin;
    animation-duration: 4;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
    vertical-align: middle;
    text-align: center;
}

@keyframes fa-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

TS:

export class HomeComponent implements OnInit
{
    isRunning = false;

    constructor(private router: Router, private page: Page, private zone: NgZone)
    {
    }

    parseResponse(data: any)
    {
        this.zone.run(() =>
        {
            if (typeof data.isRunning !== "undefined" && data.isRunning !== null)
                this.isRunning = data.isRunning;
        });
    }
}

I hope code is readable, because code formatting is not working. The code works, even error is raised.

Copied from original issue: NativeScript/nativescript-cli#2218

Copied from original issue: NativeScript/NativeScript#3089

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tomasbjerrecommented, Jun 10, 2021

I think I still see this, but in: NativeScript Vue IOS nativescript/ios: 7.1.1 vue: 2.6.12

Error:

Error: Animation cancelled.
    at Animation._rejectAnimationFinishedPromise (file:///X.app/app/vendor.js:20563:18)
    at AnimationDelegateImpl.animationFinishedCallback [as _finishedCallback] (file:///X.app/app/vendor.js:20951:16)
    at AnimationDelegateImpl.animationDidStopFinished (file:///X.app/app/vendor.js:20860:12)"
1reaction
vultixcommented, May 17, 2018

@NickIliev

Here is the playground demonstrating the error I am getting.

A few notes while creating this playground:

  • Seeing this exception throughout the app I am creating I thought it would easy to reproduce in a playground, but wasn’t. I had to bring some specific code for the playground.
  • This exception is thrown both by using *ngIf="val" and [class.animate]="val" to trigger the animation.

If you have any questions, let me know! Thanks for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular 6 animation *ngIf, transition not work - Stack Overflow
Angular is unable to calculate the transition between the closed / open states as the element simply does not exist when isMenuOpen is...
Read more >
Angular: using animations with NgIf - Useful Development
The component has an input property called show. When set to true the component needs to add the content to the dom, in...
Read more >
Get Better Angular UX Using 4 Animation Techniques - Auth0
The animations array in the component decorator ( addToCartText ) applies a horizontal transform to the element as it enters and leaves the...
Read more >
Angular Ngif Animation Bug - StackBlitz
import { Component } from '@angular/core';. @Component({. selector: 'my-app',. templateUrl: './app.component.html',. styleUrls: [ './app.component.css' ]. }).
Read more >
Developer Guide: Animations - AngularJS: API
When nesting elements with structural animations, such as ngIf , into elements that have class-based animations such as ngClass , it sometimes happens...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found