Reputation: 25
I was wondering if anyone knows how to create a diagonal line using jquery and animate it so that when it appears its drawn on rather than just appears?
Also need the same for a circle.
A simple jsfiddle would be awesome.
Muchos for the help!!
Upvotes: 2
Views: 2251
Reputation: 37179
You could actually do it with pure CSS:
HTML:
<div class='box'></div>
CSS:
.box {
overflow: hidden;
outline: dotted 1px;
width: 8.09em; height: 5.88em;
background: linear-gradient(36deg,
transparent 49.5%, black 49.5%, black 50.5%, transparent 50.5%)
no-repeat -8.09em -5.88em;
background-size: 100% 100%;
animation: drawDiag 2s linear forwards;
}
@keyframes drawDiag {
to { background-position: 0 0; }
}
HTML:
<div class='circle'>
<div class='cover'></div>
</div>
CSS:
.circle {
overflow: hidden;
position: relative;
width: 10em; height: 10em;
}
.circle:before {
position: absolute;
width: inherit; height: inherit;
border-radius: 50%;
box-shadow: inset 0 0 0 1px black;
content: '';
}
.cover {
position: absolute;
margin: 0 -50%;
width: 200%; height: inherit;
transform-origin: 50% 0;
background: white;
animation: revealCircle 5s linear forwards;
}
@keyframes revealCircle {
to { transform: rotate(180deg); }
}
Upvotes: 1