Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular Animation not Working #32

Open
davidgear opened this issue Apr 17, 2018 · 1 comment
Open

Angular Animation not Working #32

davidgear opened this issue Apr 17, 2018 · 1 comment

Comments

@davidgear
Copy link

Hello,

I have a problem using this plugin in my Ionic Application for an iOS App.

I want a transform-animation ( transform: 'rotateY(180deg)' ) to start when device is shaken.
The animation works perfectly when triggering it by a click or by itself after waiting like 2 seconds.

I have a method, which changes the variable to trigger the animation:

@Component({
...
animations: [
    trigger('state', [
      state('active', style({
        transform: 'rotateY(180deg)'
      })),
      transition('* => active', animate('400ms ease'))
    ])
  ],
...
})
export class MyComponent {

  constructor( private shake: Shake, private platform: Platform ){
    if( this.platform.ready() === 'cordova' ){
      this.shake.startWatch(40).subscribe( () => this.toggleState() );
    }
  }

  toggleState() {
    this.state = this.state === 'inactive' ? 'active' : 'inactive';
  }

}

So by shaking my iPhone I get correct outputs in the Xcode debug console and the state-variable changes from inactive to active, but the rotateY-animation will not be shown.
By clicking a button with (click)="toggleState()" property, everything works perfectly.

Can anybody help me?

@abdel-ships-it
Copy link

this.platform.ready() will never equal cordova... Because it returns a promise. So your shake listener is never set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants