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.

feat: Support animation style prop from IonContent

See original GitHub issue

Feature Request

Ionic version:

[x] 4.x

Describe the Feature Request Please support animation for IonContent element.

Describe Preferred Solution Include new prop to support animation style.

Describe Alternatives Adding the value via TS, but it’s not working. e.g:

const contentElement = (this.content['el'] as HTMLElement);
const innerScroll = contentElement.shadowRoot.querySelector('.inner-scroll') as HTMLElement;
innerScroll.style.animation = 'background 30s ease infinite';

Related Code

ion-content {
  --background: linear-gradient(124deg, #ff2400, #e81d1d, #e8b71d, #e3e81d, #1de840, #1ddde8, #2b1de8, #dd00f3, #dd00f3);
  --animation: background 30s ease infinite;
}

@keyframes background {
    0%{background-position:0% 50%}
    50%{background-position:100% 50%}
    100%{background-position:0% 50%}
}

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Isaac-curacommented, Nov 21, 2019

this work for me, put this in your page component

@ViewChild(IonContent,{static:false}) set content(content){
    if(content){
      let shadow = content.el.shadowRoot;
      let animationStyle = new CSSStyleSheet();
      (<any>animationStyle).replace(`
      :host{
        --animation-duration: 0s;
          --animation-timing-function: ease;
          --animation-delay: 0s;
          --animation-iteration-count: 1;
          --animation-direction: normal;
          --animation-fill-mode: none;
          --animation-play-state: running;
          --animation-name: none;
      }
      .inner-scroll{
        animation-duration: var(--animation-duration);
          animation-timing-function: var(--animation-timing-function);
          animation-delay: var(--animation-delay);
          animation-iteration-count: var(--animation-iteration-count);
          animation-direction: var(--animation-direction);
          animation-fill-mode: var(--animation-fill-mode);
          animation-play-state: var(--animation-play-state);
          animation-name: var(--animation-name);
      }
      `);
      shadow.adoptedStyleSheets = shadow.adoptedStyleSheets.concat(animationStyle);
    }
  }

then in your page.sccs add this for example

ion-content{
  --animation-name:perro
}

and the same for the rest of properties that you need

1reaction
liamdebeasicommented, Nov 21, 2019

Thanks for the issue. I am going to close this as we are going to be rolling out a broader animation solution in the next major release of Ionic Framework that should account for this use case. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support animation style prop from IonContent · Issue #19957 ...
Describe Preferred Solution Include new prop to support animation style. ... feat: Support animation style prop from IonContent #19957.
Read more >
Animations - Ionic Framework
Ionic apps use Web Animations API to build and run animations. Learn how this utility lets developers build complex animations in a platform...
Read more >
An Introduction To React With Ionic - Smashing Magazine
You are going to create a reusable React component in this step. This component will receive data and display information about a comic....
Read more >
ionic/docs/core.json - UNPKG
79, "docs": "Animation to use when the action sheet is presented.", ... IonButton, IonContent } from '@ionic/react';\n\nexport const ...
Read more >
Implementing HTML5 canvas in Ionic - Mastering Ionic
From drawing geometric shapes and manipulating image pixel data to creating advanced animations the HTML5 Canvas API opens up a world of ...
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