3

We have a web-page that starts with some animation: coara

For performance and SEO reasons we normally pre-render our pagees into a static HTML using Angular Universal.

Problem here: The animation re-starts when the DOM is replaced by the Angular code. Is there a way to avoid this, or to wait with DOM replacement until the animation has finished (and not start it again)?

2
  • Did you find a solution to this problem? I have the same issue. Nice website btw :) Commented Nov 14, 2019 at 14:49
  • @Vingtoft I think in the end we removed this animation. Commented Mar 24, 2020 at 10:35

1 Answer 1

1

You could add a fake provider on your app.module.ts to know where the component is rendered:

 providers: [
    {
      provide: "isBrowser",
      useValue: true,
    },
  ],

and this import on your app.server.module.ts

 providers: [
    {
      provide: "isBrowser",
      useValue: false,
    },
  ],

Then you can import this "provider" on your component like this:

constructor(@Inject("isBrowser") public enableAnimations: boolean) {}

Now you can disable animations when the component is load on server side and add the animation on client side.

Sign up to request clarification or add additional context in comments.

1 Comment

This doesn't solve the following though: Run the animation on the pre-rendered HTML and then not run it again on the client side rendered HTML. Any suggestions for that?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.