Harvest-Dev / ng-walkthrough

A walkthrough for Angular
MIT License
21 stars 8 forks source link

Cannot get 'pause' of null #27

Closed tjvg91 closed 5 years ago

tjvg91 commented 5 years ago

Why do I get this error?

ERROR TypeError: Cannot read property 'pause' of null`
    at WalkthroughComponent.open (angular-walkthrough.js:704)`
    at WalkthroughFlowComponent.start (angular-walkthrough.js:1964)`

image

This is my code:

@ViewChild('walkFlow1') walkFlow1: WalkthroughFlowComponent;
this.walkFlow1.start();

This is my markup:

<ng-walkthrough-flow
   focusBackdrop="true"
   focusHighlightAnimation="true"
   closeButton="true"
   closeAnywhere="false"
   showArrow="true"
   radius="auto" #walkFlow1>

   <ng-walkthrough id="walk-to-title"
      focusElementSelector="#hymnTitle"
      contentText="Tap to browse hymns in the hymnal">
   </ng-walkthrough>

</ng-walkthrough-flow>
Zefling commented 5 years ago

It's really your code ? Where is the start is the lifecycle of your component ?

tjvg91 commented 5 years ago

Well I did import the module in app.module.ts

...
import { WalkthroughModule } from 'angular-walkthrough';
...
@NgModule({
...
  imports: [
    BrowserModule,
    CommonModule,
    HttpModule,
    BrowserAnimationsModule,
    WalkthroughModule,
    IonicModule.forRoot(MyApp),
  ],
...
});
export class AppModule{}

That's it.

Zefling commented 5 years ago

“lifecycle of your component” : ngOnInit, ngAfterContentInit, ngAfterViewInit

tjvg91 commented 5 years ago

I put my code inside ionViewDidLoad

...
import { Component, OnDestroy, ViewChild, ElementRef, HostListener } from '@angular/core';
import { WalkthroughFlowComponent } from 'angular-walkthrough'
...
@IonicPage()
@Component({
...
})
export class ReaderPage implements OnDestroy{
   ...
   @ViewChild('walkFlow1') walkFlow1: WalkthroughFlowComponent;
   ...
   constructor(...){...}

   ionViewDidLoad(){
      ...
      this.walkFlow1.start();
   }

   ngDestroy(){...}

No ngOnInit, ngAfterContentInit, or ngAfterViewInit

Zefling commented 5 years ago

Hoo, it's with Ionic... Sorry, it don't use it.

Zefling commented 5 years ago

For information, the module injects an external component in the body. Without body, this module doesn't work. 2018-10-26_14h31_06

If this different in an Ionic application, thank to explain what it looks like.

tjvg91 commented 5 years ago

Does the lifecycle matter that much? When do the walkthrough elements appear? And yes I have that walkthrough-container element.

Zefling commented 5 years ago

I have add a fix. Please, test with 0.7.3.