Animating SVG paths with discontinuous parts
Here is an approach using several path elements and using animation-delay to make the lines draw one after the other :
path{ stroke-dasharray:10; stroke-dashoffset:10; fill:none; stroke:#000;}path:nth-child(1){animation:draw1 4s linear infinite}path:nth-child(2){animation:draw2 4s linear infinite}path:nth-child(3){animation:draw3 4s linear infinite}path:nth-child(4){animation:draw4 4s linear infinite}@keyframes draw1{ 20%,100% {stroke-dashoffset:0; }}@keyframes draw2{ 20% {stroke-dashoffset:10;} 40%,100% {stroke-dashoffset:0; }}@keyframes draw3{ 40% {stroke-dashoffset:10;} 60%,100% {stroke-dashoffset:0; }}@keyframes draw4{ 60% {stroke-dashoffset:10;} 80%,100% {stroke-dashoffset:0; }}
<svg width="220px" height="100px" viewBox="0 0 10 11"> <path d="M0,1 h10" /> <path d="M0,4 h10" /> <path d="M0,7 h10" /> <path d="M0,10 h10" /> </svg>
SVG animate stroke-dashoffset behaving oddly
Did you think 100% would be 100% of the length of the path? If so that's where you're going wrong as it's 100% of the viewport width. I don't think Opera and Firefox have a bug here, particularly as they happen to be displaying things identically.
d3 linechart transition with missing data
Based on the comments of Hugues Moreau it does not seem possible to achieve the result with a single path, so I've created a work-around for myself.
At the start there's an array with data, with the null-values in it.
I create a new array and add sub-arrays to this array.
var newObjectArray = [];
var duration = 2000;
var duration_per_point = duration / d.values.length;
var delay = 0;
var start = 0;
for (var j = 0; j < d.values.length; j++)
{
if (isNaN(d.values[j].y))
{
var tempArray = d.values.slice(start, j);
newObjectArray.push(tempArray );
start = j;
}
}
newObjectArray.push(d.values.slice(start, j));
for each array in the newObjectArray I now draw a path, and add delay to the transition.
linePath
.attr("stroke-dasharray", totalLength + " " + totalLength)
.attr("stroke-dashoffset", totalLength)
.transition()
.duration(duration_per_point*newObjectArray[k].length)
.delay(delay)
.ease(d3.easeLinear)
.attr("stroke-dashoffset", 0);
delay += duration_per_point * newObjectArray[k].length;
jsfiddle: https://jsfiddle.net/9kknu8du/4/
Problem with interface
Your Avatar.Cred
property is of type Account
, not IAccount
... but LogOn
is declared to return just IAccount
. So it could return some other IAccount
implementation - the compiler won't let you just assume that the IAccount
will be an Account without an explicit cast.
Options:
- Change the type of the
Cred
property toIAccount
instead ofAccount
. This is probably best as it reduces the coupling betweenAvatar
andAccount
, so you can use other implementations ofIAccount
. - Change the return type of
LogOn
toAccount
instead ofIAccount
. This ties theLogOn
API toAccount
, instead of just the implementation. Cast when you assign the property:
avatar.Cred = (Account) LogOn();
Related Topics
Angular 8: Change Height in Mat-Form-Field to Specific Pixel Number
Combining Ie6 and Ie7 CSS Hacks in Same Stylesheet
Styling Kml with CSS in Google Maps V3
CSS: Does It Render "Ul > Li" Faster Than "Ul Li"
Max-Width:-Webkit-Fit-Content Ie 8 Equivalent
Horizontally Center <P> Within a Div While Keeping The Text Left-Aligned
How to Rotate a Font Icon 45 Degrees
Square Responsive Divs Using Bootstrap 4
Why Do Browsers Render Rgba Differently on Osx
Overwriting Styles from Bootstrap in an Angular2 Component-Stylesheet
:Before and: After Selectors on Internet Explorer
Gulp-Sass Work Around for Load_Path Support
Using CSS Mix-Blend-Mode with a Child of a Position Fixed Element
CSS Rules for Webkit Based Browsers
Div Elements to Follow a Curved Path with CSS3