SVG Cross Browser (Firefox) Issues - firefox

I tried to adapt a codepen thing for waves with svgs.
Works just fine in Chrome, Safari and Edge, but not in Firefox (and IE, but I don't care too much about that).
I suspect some Syntax problem with the svg. The animation works just fine, but the svgs are not displayed correctly. In Firefox it's just a straight line instead of waves.
Anyone out there, that has an idea about that?
Thanks a lot in advance.
.waves {
width: 100%;
height: 7em;
position: relative;
overflow: hidden;
background-color: #f6f9fc;
}
.wave
{
width:calc( 100% + 4em );
height:100%;
position:absolute;
left:-2em;
background:bottom center repeat-x;
animation-iteration-count:infinite;
animation-timing-function:linear;
}
/* Individual wave layers */
.wave_1
{
animation-name:wave_1;
animation-duration:3400ms;
animation-delay:-1200ms;
z-index:2;
opacity: 1;
background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="600" height="2000" viewBox="0 0 600 2000"><path fill-rule="evenodd" clip-rule="evenodd" fill="#fff" d="M600 2000c-100.8 0-141.6-39.892-240-39.892S98.4 2000 0 2000V0h6000v2000z"/></svg>');
background-position:bottom left;
background-color: #e0e7f1;
top: -3em;
}
.wave_2
{
z-index:1;
opacity: 1;
background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="600" height="2000" viewBox="0 0 600 2000"><path fill-rule="evenodd" clip-rule="evenodd" fill="#e0e7f1" d="M600 2000c-100.8 0-141.6-39.892-240-39.892S98.4 2000 0 2000V0h6000v2000z"/></svg>');
background-position:bottom left;
background-color: #245aa6;
top: 0em;
}
#keyframes wave_1
{
from { transform: rotate(0deg) translatey(-0.61em) rotate(0deg) ; }
to { transform: rotate(360deg) translatey(-0.61em) rotate(-360deg) ; }
}
<div class="waves">
<div class="wave wave_1"></div>
<div class="wave wave_2"></div>
</div>

Related

shopify dawn theme, animate disappearing paw prints to appear in background?

I'm building a Shopify for my dog leash products. I had a cool idea to have an animated disappearing paw print path show up on random parts of the screen going in different directions, while avoiding any text. The animation would appear for a certain amount of time, for a certain frequency, and a certain number of simultaneous instances. Is there any suggestions or code to implement this animation with this type of behavior to the store's code? I don't have too much experience with website code, but I'm savvy enough to figure it out with some guidance and instruction.
Any help is greatly appreciated!
The most research I did was figuring out how to add an animation on scroll library but I'm not sure if that's in the right direction.
It's not simple like you think. You can't just copy some code and it will work. It is tricky and requires customization based on which theme you are using and how it's structured.
But if you know a little bit of CSS and JS i think you can get away with it by modifying the code below:
The HTML:
<svg id="svg-sprite">
<symbol id="paw" viewBox="0 0 249 209.32">
<ellipse cx="27.917" cy="106.333" stroke-width="0" rx="27.917" ry="35.833"/>
<ellipse cx="84.75" cy="47.749" stroke-width="0" rx="34.75" ry="47.751"/>
<ellipse cx="162" cy="47.749" stroke-width="0" rx="34.75" ry="47.751"/>
<ellipse cx="221.083" cy="106.333" stroke-width="0" rx="27.917" ry="35.833"/>
<path stroke-width="0" d="M43.98 165.39s9.76-63.072 76.838-64.574c0 0 71.082-6.758 83.096 70.33 0 0 2.586 19.855-12.54 31.855 0 0-15.75 17.75-43.75-6.25 0 0-7.124-8.374-24.624-7.874 0 0-12.75-.125-21.5 6.625 0 0-16.375 18.376-37.75 12.75 0 0-28.29-7.72-19.77-42.86z"/>
</symbol>
</svg>
<div class="ajax-loader">
<div class="paw"><svg class="icon"><use xlink:href="#paw" /></svg></div>
<div class="paw"><svg class="icon"><use xlink:href="#paw" /></svg></div>
<div class="paw"><svg class="icon"><use xlink:href="#paw" /></svg></div>
<div class="paw"><svg class="icon"><use xlink:href="#paw" /></svg></div>
<div class="paw"><svg class="icon"><use xlink:href="#paw" /></svg></div>
<div class="paw"><svg class="icon"><use xlink:href="#paw" /></svg></div>
</div>
The CSS:
.ajax-loader{
position: absolute;
top: 25%;
left: 50%;
transform-origin: 50% 50%;
transform: rotate(90deg) translate(-50%, 0%);
font-size: 50px;
width: 1em;
height: 3em;
color: #d31145;
.paw{
width: 1em;
height: 1em;
animation: 2050ms pawAnimation ease-in-out infinite;
opacity: 0;
svg{
width: 100%;
height: 100%;
}
.icon{
fill: currentColor;
}
&:nth-child(odd){
transform: rotate(-10deg);
}
&:nth-child(even){
transform: rotate(10deg) translate(125%, 0);
}
#for $i from 1 through 6{
&:nth-child(#{$i}){
animation-delay: #{ (($i * -1)+6)*0.25 }s;
}
}
.no-cssanimations &{
opacity: 1;
}
}
}
#keyframes pawAnimation {
0%{
opacity: 1;
}
50%{
opacity: 0;
}
100%{
opacity: 0;
}
}
This code is one of the 4 examples i found online, i hope they can help you:
https://codepen.io/motionimaging/pen/MKrQXa
https://codepen.io/ngets/pen/qMXgrq
https://codepen.io/kylojen/pen/VxXXNm
https://codepen.io/trungk18/pen/BLYNmM

SVG Circle not animated in Edge

The below svg animates perfectly in all browsers but Edge (surprise!).
<svg width="80" height="24" viewBox="0 0 120 30" xmlns="http://www.w3.org/2000/svg" fill="#555">
<circle cx="15" cy="15" r="15">
<animate attributeName="r" from="15" to="15"
begin="0s" dur="0.8s"
values="15;9;15" calcMode="linear"
repeatCount="indefinite" />
<animate attributeName="fill-opacity" from="1" to="1"
begin="0s" dur="0.8s"
values="1;.5;1" calcMode="linear"
repeatCount="indefinite" />
</circle>
</svg>
I tried adding px as units but no luck.
Thanks for your tips!
I try to check your code and refer to the MDN documentation.
I can see that you are using animate, attributeName, from, to, dur attributes in your code.
Animate is supported in Edge version <=79.
Whereas compatibility is unknown for attributeName, from, to, dur
Reference:
SVG Animate
I think this is the reason why your code is not working in the MS edge legacy browser.
I suggest you recommend your clients use the MS Edge Chromium browser or you can remove the animation or show the image in place of animation to avoid the issue.
After reading the comments and answers I decided to go for clear CSS animation, instead of SVG. I grabbed the code from https://projects.lukehaas.me/css-loaders/ and my "solution" looks like this:
<style>
.loader,
.loader:before,
.loader:after {
border-radius: 50%;
width: 2.2em;
height: 2.2em;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation: load7 1.3s infinite ease-in-out;
animation: load7 1.3s infinite ease-in-out;
}
.loader {
color: #888;
font-size: 10px;
margin: 80px auto;
position: relative;
text-indent: -9999em;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s;
}
.loader:before,
.loader:after {
content: '';
position: absolute;
top: 0;
}
.loader:before {
left: -3.5em;
-webkit-animation-delay: -0.32s;
animation-delay: -0.32s;
}
.loader:after {
left: 3.5em;
}
#-webkit-keyframes load7 {
0%,
80%,
100% {
box-shadow: 0 2.2em 0 -1.3em;
}
40% {
box-shadow: 0 2.2em 0 0;
}
}
#keyframes load7 {
0%,
80%,
100% {
box-shadow: 0 2.2em 0 -1.3em;
}
40% {
box-shadow: 0 2.2em 0 0;
}
}
</style>
<div class="loader">Loading...</div>

How to create a responsive svg border animation

I want to create a border animation for a button element. The design is that the ends of the slanted rectangle are open and then close on hover.
This is what we're trying to do (excuse my artistic "style"):
Here's some code and a codepen example:
a svg rect {
stroke: red;
stroke-width: 5;
transition: 1s;
stroke-dasharray: 100%;
stroke-dashoffset: 0;
}
a:hover svg rect {
stroke-dasharray: 0%;
stroke-dashoffset: 0;
}
codepen example
I'm having trouble understanding the math behind stroke-dasharray, but it seems this should be possible without too much complex math.
The other issue is that it would need to be responsive. So the button can contain different amounts text.
Let me know if you need further clarification.
Here is, I think, about the best you can do to create an automatically responsive button that meets your requirements.
It has a couple of failings:
The gap in the outline of the button varies in size based on the label length.
It needs a fairly recent browser (in order to support pathLength on a <rect> element)
.btn {
display: inline-block;
position: relative;
overflow: auto;
}
.btn + .btn {
margin-left: 20px;
}
.btn svg {
position: absolute;
top: 0;
left: 0;
}
.label {
position: relative;
font-size: 18px;
font-weight: bold;
padding: 5px 20px;
}
.btn, .btn svg {
overflow: visible;
}
.btn svg rect {
fill: gold;
stroke: black;
stroke-width: 2px;
stroke-dasharray: 47 3;
transform-origin: 50% 50%;
transform-box: fill-box;
transform: skewX(-10deg) scale(1, -1);
transition: all 0.75s;
}
.btn:hover svg rect {
stroke-dasharray: 50 0;
stroke-dashoffset: 50;
}
<div class="btn">
<svg width="100%" height="100%">
<rect width="100%" height="100%" pathLength="100"/>
</svg>
<div class="label">Button</div>
</div>
<div class="btn">
<svg width="100%" height="100%">
<rect width="100%" height="100%" pathLength="100"/>
</svg>
<div class="label">Much longer button</div>
</div>
Instead of using a skewed svg element I'm using a polygon. This way I can calculate the total length (perimeter length) of the polygon. I've done this using javascript: console.log(poly.getTotalLength()). This gave me 543.7. For the polygon's stroke-dasharray I'm using 250, 21.85 where 250 + 21.85 = 543.7 / 2.
I'm animating the stroke-dashoffset to 543.7 / 2 = 271.85; and stroke-dasharray to 271.85 0. (the stroke goes from 250 to 271.85 and the gap from 21.85 to 0)
Another change I've made: I'm using a svg <a> element instead of the one you are using and the polygon has pointer-events:all; I've added this to make it sensitive to the mouse although the fill:none.
I hope you'll find this useful.
polygon {
stroke: red;
stroke-width: 4;
stroke-dasharray:250, 21.85;
fill: none;
transition: 1s;
pointer-events:all;
}
polygon:hover{
stroke: #ff0;
stroke-dashoffset: 271.85;
stroke-dasharray: 271.85 0;
}
<svg viewBox = "0 0 250 50" width="250">
<a xlink:href="#" class="py-2 px-5">
<text x="125" y="30" text-anchor="middle">Button Button Button</text>
<polygon id="poly" points="2,48 220,48 248,2 30,2 2,48" />
</a>
</svg>

Css3 animation blowing bubble

I'm making a CSS3 animation in which I want a bubble to appear like it is blown from a pipe like a real bubble. Can any one guide how to do that?
Like this drop appears in the upper image the bubble should appear like a real bubble. This is what I have done so far, but it doesn't look good! It seems like phone is coming out of a square. Is there any way to make it look like its coming out of a bubble?
#Capa_2{
position: absolute;
overflow: visible;
top: 100px;
}
#Capa_1{
position: absolute;
top: 60px;
left: 68px;
animation: vibrate 0.1s 4s 3;
}
#chat {
opacity: 0;
animation: grow 3s 2s ease-in forwards;
}
#keyframes grow {
0% {
/*transform: scale(2,2);*/
}
40% {opacity: 1;
transform: scale(2.5,1.6) translate(300px,-350px);
}
70% {opacity: 1;
transform: scale(2.4,1.5) translate(300px,-280px);
margin-left: -2px;
margin-top: 2px;
}
100% {opacity: 1;
transform: scale(2,2) translate(300px,-350px);
margin-left: 0px;
margin-top: 0px;
}
}
#phone {
opacity: 0;
animation: ring 2.5s 4.5s forwards;
}
#keyframes ring {
0% {
opacity: 1;
transform: translateX(-900px) rotate(0deg);
}
100% {
transform: translateX(2px) rotate(360deg);
opacity: 1;
}
}
#phone {
opacity: 0;
animation: ring 2.5s 2s forwards;
}
#keyframes vibrate {
0% {margin-left: 0px;}
25% {margin-left: -3px;}
50% {margin-left: 0px;}
75% {margin-left: 3px;}
100% {margin-left: 0px;}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<link href="button.css" rel="stylesheet" media="all">
</head>
<body>
<div>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_2" x="0px" y="0px" width="32px" height="32px" viewBox="0 0 435.244 435.244" style="enable-background:new 0 0 435.244 435.244;" xml:space="preserve">
<g>
<g>
<path id="chat" d="M75.146,425.343v-96.354C27.281,294.43,0,244.745,0,191.603C0,91.414,97.624,9.901,217.622,9.901 s217.622,81.513,217.622,181.701c0,100.186-97.624,181.701-217.622,181.701c-14.218,0-28.533-1.189-42.631-3.539L75.146,425.343z M217.622,39.177c-103.854,0-188.346,68.379-188.346,152.425c0,45.561,25.014,88.418,68.636,117.568l6.504,4.346v62.022 l65.497-36.452l5.2,0.973c14.021,2.63,28.321,3.968,42.508,3.968c103.856,0,188.346-68.376,188.346-152.425 C405.968,107.556,321.479,39.177,217.622,39.177z" fill="#000000"/>
</g>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 760.025 760.025" style="enable-background:new 0 0 460.025 460.025;" xml:space="preserve" width="62px" height="62px">
<path id="phone" d="M354.363,271.978c-11.661-22.385-28.972-40.292-51.43-53.211c-8.664-5.009-16.844-7.445-25.008-7.445 c-3.176,0-6.362,0.383-9.489,1.134c-10.368,2.513-20.326,7.363-30.442,14.831c-3.194,2.357-7.101,3.551-11.614,3.551 c-5.494,0-11.444-1.886-15.518-4.921c-29.574-22.047-54.67-47.141-76.712-76.711c-4.334-5.82-7.769-18.471-1.376-27.136 c7.47-10.118,12.322-20.077,14.837-30.461c2.694-11.19,0.629-22.467-6.3-34.455C128.376,34.669,110.468,17.359,88.089,5.7 C80.837,1.92,73.416,0,66.033,0C53.686,0,42.13,5.363,32.62,15.499c-8.742,9.303-16.471,19.154-25.389,31.082 C-0.932,57.51-0.259,70.117,0.336,81.24l0.015,0.237c1.002,14.108,6.272,30.804,16.11,51.025 c16.643,34.227,40.282,66.727,72.261,99.354c6.569,6.708,32.767,32.907,39.479,39.476c32.634,31.989,65.134,55.626,99.355,72.267 c20.226,9.839,36.917,15.107,51.029,16.111l0.237,0.015c2.903,0.155,6.006,0.3,9.026,0.3c0.001,0,0.001,0,0.001,0 c7.451,0,17.097-0.818,25.631-7.198c11.931-8.916,21.784-16.646,31.074-25.378C360.843,312.168,364.508,291.429,354.363,271.978z" fill="#1F45FC"/>
</svg>
</div>
</body>
</html>

firefox 35.0.1: svg mask animation doesn't work

after my firefox update to version 35.0.1 my svg animations doesn't work in firefox, but it was working in previous versions and it still works in firefox beta (36), nightly (37.0a2) and other browsers (opera, chrome, safari, modern ie):
html:
<svg version="1.1" id="logo-svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="55px" height="53.758px" viewBox="-1061.986 3038.43 55 53.758" enable-background="new -1061.986 3038.43 188.279 53.758" xml:space="preserve">
<g id="logo-mask" >
<rect id="sygnet" fill="#FFFFFF" x="-1100" y="3038" width="100" height="50"/>
</g>
<g id="logo-black">
<rect id="sygnet" fill="#000000" x="-1100" y="3038" width="100" height="50"/>
</g>
</svg>
<div id="button">Click me!</div>
css:
body{
background-color: #777777;
}
#button{
margin-right: 100px;
display: block;
width: 100px;
height: 20px;
float: right;
background-color: #fff;
cursor: pointer;
text-align: center;
line-height: 20px;
}
js (using snap.svg):
$(document).ready(function(){
var s = Snap(),
svg = Snap.select('#logo-svg'),
logo = Snap.select('#logo-mask'),
logoBlack = Snap.select('#logo-black'),
mask = svg.rect(-1100, 2830, 280, 100).attr({
fill: 'white',
id: 'maska-logo'
});
logoBlack.attr({'mask': mask, 'opacity': 1});
});
$(document).on('click', '#button', function(){
var maska = Snap.select('#maska-logo');
maska.animate({
transform: 'T'+[0,200]
}, 500);
});
simple example: http://jsfiddle.net/7yq14L0f/2/
any idea, why? :(
It was caused by a change in the Firefox code which was not completely correct and which was then fixed. Bug 932771 caused it and bug 1127507 which was backported as far as Firefox 36 fixed it.

Resources