Run animation again on hover - animation

I created an anim https://designordering.com/resume/. I would like to run the animation again on hover.
.circle1 {
fill: none;
stroke: #000;
stroke-width: 5px;
stroke-dasharray: 345;
stroke-dashoffset: 320;
animation: anim 2s linear forwards;
}
#keyframes anim {
100% {
stroke-dashoffset: 157.5;
}
}
/*I was trying this doesn't work*/
:hover {
animation-play-state: running;
}
<div class="app-skills">
<div class="app-circle">
<div class="outer">
<div class="inner">
<img class="app-logos" src="http://127.0.0.1:5500/img/Adobe-Illustrator.png" alt="js logo" width="35px">
</div>
</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100px" height="100px">
<circle class="circle1" cx="45" cy="45" r="40"
stroke-linecap="round" />
</svg>
</div>
<div class="app-name">
<p>Adobe<br> Illustrator</p>
</div>
</div>
Can you help me with advices? thank you so much!
The animation starts when the page is loaded but I would like to run it again when someone hover over the circle. It is important to run twice (or as much time someone hover over it). Thank you so much again in advence to your advices.

I see you've discovered one of the most annoying flaws in the SVG standard: the lack of an easy way to restart animations! Luckily, you only have 1 element to restart.
First: don't use "fill: none;" use "transparent" instead. When you use "none", the hit area will be the width of the stroke only -- not the entire inside of the circle! I'm pretty sure you do not want someone having to precisely hover over the stroke itself.
On hover, use a second keyframe, like this:
circle:hover{
animation: anim2 2s 1 linear forwards;
}
You need the whole animation declaration. Can't just do "animation-name"
Here's my whole fiddle:
https://jsfiddle.net/zombiedoctor/y0qwbu84/

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

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>

Center image in body with fullpage.js

Due to SEO reasons I put my images into the body section rather than as background pictures like so:
<div id="fullpage">
<div class="slide" ><img class="l-cover" data-src="imagelink1"></div>
<div class="slide" ><img class="l-cover" data-src="imagelink2"></div>
<div class="slide" ><img class="l-cover" data-src="imagelink3"></div>
</div>
I tried to style the images like here:
https://jsfiddle.net/gnq52ygu/
I want the pictures to center, when the screen gets smaller. Right now the pictures stay fix at the left side.
As soon as I style the img tag there's some conflict with fullscreen.js.
Can anyone help me please?
Perfectly center? Both horizontally and vertically? This can be done like so:
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

onmouseover and onmouseout fade effect

I'm looking for a solution to add a fadein and fadeout effect to this line of code:
<img src="images/1.jpg" onmouseover="this.src='images/2.jpg'"
onmouseout="this.src='images/1.jpg'" alt="fade_me" />
Does anyone have any simple solutions without this becoming too complex? Thanks!
Well, I don't know about complexity, but this works pretty well.
http://jsfiddle.net/8KFT8/1/
<style>
.container {
position: relative;
}
.container img {
position: absolute;
transition: opacity .5s ease;
}
.container img:hover {
opacity: 0;
}
</style>
<div class="container">
<img src="images/2.jpg"/>
<img src="images/1.jpg"/>
</div>

<div> height rendering issue with Firefox

I created a div that transitions from a beginning height to a larger height, revealing a list. It looks fine in web-kit browsers but in Firefox the div appears to come up short, cutting off the bottom of the list.
I tried setting the div height in em hoping that the div would then match the height to the font size used in the list. Still the same thing occurs.
Any ideas?
CSS:
#nav{
padding:0;
position:fixed;
top:27px;
left:27px;
font-family:arial;
font-size:10px;
background-color:#ccc;
width:11.3em;
height:5.5em;
overflow:hidden;
transition: height .5s;
-webkit-transition: height .5s; /* Safari */
}
#nav:hover{
height:22em;
}
#nav a.bg:hover{
background-color: #ccc;
}
#nav a{
text-decoration:none;
color:#000;
}
#nav a:hover{
background-color:#6a6a6a;
}
HTML:
<div id="top">
<div id="nav">
<!--logo_image-->
<a class="bg" href="#"><img src="b&w_logo.jpeg" height="56" width="110" /></a>
<!---->
<div style="height:1em;"></div>
<div style="font-size:1.1em;"><b>Artists</b></div>
<div style="height:1em;"></div>
<div>Ahnnu</div>
<div>Gem Vision</div>
<div>Dope Body</div>
<div>Co La</div>
<div>Teenage Souls</div>
<div>Kid Krusher</div>
<div>Lil Jabba</div>
<div>Cex</div>
<div>Teeth Mountain</div>
<div>Jimmy joe Roche</div>
</div>
</div>
U have 2 options I think:
One is called CSS reset - http://html5reset.org/
The second one is called Normalize. Instead of resetting all styles, it targets the ones that need to change to give you sane, consistent results across browsers in a smaller file size. http://necolas.github.com/normalize.css/

Resources