0

Here is the HTML:

<div id="container">
    <svg>
        <path id="polyline" d="
            M0,5
            L184,5
            C205,4 202,6 202,13
            L202,86
            L327,86
            L421,166
            L460,166
            L499,132
            L588,211
            L617,211
            L712,134
            L748,165
            L780,165
            L830,111
            L913,212
            L938,212
            L1028,140
            L1078,184
            L1107,184
            L1152,140
            L1263,249"
        />
        <defs>
            <pattern id="pattern" width="1920" height="1080" patternUnits="userSpaceOnUse">
                    <image xlink:href="forest.jpg" width="1920" height="1080" />
            </pattern>
        </defs>
    </svg>
</div>

Here is the CSS:

#container {
    width:1263px;
    height:255px;
    position:absolute;
}
#container svg {
    width:100%;
    height:100%;
    fill:none;
    stroke:url(#pattern);
    stroke-dasharray:1626.7125244140625;
    stroke-dashoffset:1627;
    stroke-linecap:square;
    stroke-width:8;
    animation:polyline 3.15s linear 0.5s forwards;
}
@keyframes polyline {
    to {
        stroke-dashoffset:0;
    }
}

DEMO

  • All of this works fine in Chrome.
  • It works in Edge without stroke-dashoffset and thus without the animation.
  • It does not work at all in Firefox/Waterfox.

Is there a way to achieve this effect across browsers?

Or is there something wrong with my code?

Thanks in advance! <333

  • Can't repro on FF in codepen, However, you have to know that if the CSS part isn't in the document, then the `url()` won't be the good one (see http://stackoverflow.com/questions/32146904/svg-clip-path-works-in-chrome-but-not-in-firefox-or-safari) – Kaiido Dec 30 '15 at 06:51
  • You're relying on a Chrome bug here as I've explained in your other question/answer. – Robert Longson Dec 30 '15 at 10:11
  • @Kaiido thanks so much man!!! **<333** –  Dec 31 '15 at 01:44
  • @RobertLongson Yeah, I haven't got a chance to look at that yet. But I saw your answer on the question that Kaiido linked, which worked like a charm. Thanks! –  Dec 31 '15 at 01:45

1 Answers1

0

Tested in Firefox (latest) worked fine, however, according to link animation is supported in FireFox with its own prefix:

  -moz-animation: polyline 3.15s linear 0.5s forwards;
LOTUSMS
  • 10,317
  • 15
  • 71
  • 140
  • It actually works fine in Firefox/Waterfox without the prefix, as long I'm using a color as a stroke. I'll double check and see if it, for whatever reason, works with the prefix, though. –  Dec 30 '15 at 02:08
  • Yeah, I just double checked. Still not working in Firefox/Waterfox, even with the prefixes. The demo works fine, just not as independent page. –  Dec 30 '15 at 02:11
  • gotcha! Well, it was worth a try. I'll delete the answer in a minute then so no one gets confused. – LOTUSMS Dec 30 '15 at 02:13
  • Good idea. Probably best to get rid of it. Thanks for the attempt anyways. –  Dec 30 '15 at 08:07