Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Svg animations not running on Safari

We are working on a web app ( react ) with SVG animations. Our SVG animations are working great on the desktop web and Android web, but do not animated ios devices (testing on Safari on iPhone 5s, 8 and MacBook Pro).

const AnimationFooter = styled.div`
  margin-top: -18rem;
  height: auto;
  width: 100%;
  position: relative;

  @media (max-width: 420px) {
    margin-top: -15rem;
  }
  @media (max-width: 360px) {
    margin-top: -14rem;
  }
`;


const Im = styled.img`
  width: 100%;
  height: auto;
  /* -webkit-transform: translateZ(0); */

  @media (max-width: 420px) {
    margin-top: 6px;
  }
`;



<div>
   <AnimationFooter>
            <Im src="../static/images/home-image-ground.svg" />
     </AnimationFooter>
</div>
like image 933
Mithila Eranda Avatar asked Jan 08 '19 07:01

Mithila Eranda


People also ask

Why is my SVG not animating?

One of the most common reasons why the SVG animation doesn't work is the use of <img> tags to add the SVG. The SVG might be visible on the website, but the animation will not start. You can easily fix this by replacing all <img> tags with an <object> tag.

Does SVGs support animation?

SVG supports the ability to change vector graphics over time, to create animated effects. SVG content can be animated in the following ways: Using SVG's animation elements [svg-animation]. SVG document fragments can describe time-based modifications to the document's elements.


1 Answers

Try it in this way.

 const PetTabs = styled.div`
     .react-tabs__tab {
       width: 250px;
       margin-left: 40px;
       margin-right: -40px;
       border-color: #454440;
       border-width: 1px 1px 1px 1px;
       border-radius: 15px 15px 0 0;
       background-color: #454440;
       color: #ffffff;
     }

     .react-tabs__tab--selected {
       background-color: #ffffff;
       color: #454440;
     }

     .react-tabs__tab--selected :before,
     .react-tabs__tab--selected :after {
       position: absolute;
       bottom: -1px;
       width: 16px;
       height: 19px;
       content: ' ';
     }

     .react-tabs__tab--selected :after,
     .react-tabs__tab--selected :before {
       border: 1px solid #454440;
     }
     .react-tabs__tab--selected :before {
       left: -17px;
       margin-bottom: 1px;
       border-bottom-right-radius: 16px;
       border-width: 0 1px 1px 0;
       box-shadow: 7px 9px 0 #ffffff;
     }
     .react-tabs__tab--selected :after {
       right: -17px;
       margin-bottom: 1px;
       border-bottom-left-radius: 16px;
       border-width: 0 0 1px 1px;
       box-shadow: -6px 5px 0px 4px #ffffff;
       z-index: 15
     }
    `;
like image 184
Nipun Ravisara Avatar answered Oct 01 '22 21:10

Nipun Ravisara