Skip to content

Commit

Permalink
Animation of percent property values (e.g. pie charts) not working #2099
Browse files Browse the repository at this point in the history


Normally, a value in preferred units can be parsed back in a cycle.  This is not the case for percent values.  The preferred values range on [0, 1] whereas they are parsed as implicitly having `%` at the end if just a number is specified.  Consider for v4 changing parsing for percent values s.t. unitless values range on [0, 1] and values with `%` range on [0, 100].  For now, just add a case for percent units to use `value` instead of `pfValue`.
  • Loading branch information
maxkfranz committed May 2, 2018
1 parent 27575ca commit b253f95
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/core/animation/ease.js
Expand Up @@ -26,6 +26,18 @@ function getEasedValue( type, start, end, percent, easingFn ){
return val;
}

function getValue( prop, spec ){
if( prop.pfValue != null || prop.value != null ){
if( prop.pfValue != null && (spec == null || spec.type.units !== '%') ){
return prop.pfValue;
} else {
return prop.value;
}
} else {
return prop;
}
}

function ease( startProp, endProp, percent, easingFn, propSpec ){
let type = propSpec != null ? propSpec.type : null;

Expand All @@ -35,19 +47,8 @@ function ease( startProp, endProp, percent, easingFn, propSpec ){
percent = 1;
}

let start, end;

if( startProp.pfValue != null || startProp.value != null ){
start = startProp.pfValue != null ? startProp.pfValue : startProp.value;
} else {
start = startProp;
}

if( endProp.pfValue != null || endProp.value != null ){
end = endProp.pfValue != null ? endProp.pfValue : endProp.value;
} else {
end = endProp;
}
let start = getValue( startProp, propSpec );
let end = getValue( endProp, propSpec );

if( is.number( start ) && is.number( end ) ){
return getEasedValue( type, start, end, percent, easingFn );
Expand Down

0 comments on commit b253f95

Please sign in to comment.