Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
enterTransition = enterTransition.attrTween('r', function(d, i, g) {
const that: SVGCircleElement = this;
// const that2: HTMLElement = this; // fails, type mismatch
const datum: CircleDatum = d;
const index: number = i;
const group: SVGCircleElement[] | ArrayLike = g;
console.log(this.r.baseVal.value); // this type is SVGCircleElement
return interpolateString(0, d.r); // datum type is CircleDatum
});
enterTransition = enterTransition.attrTween('r', function(d, i, g) {
const that: SVGCircleElement = this;
// const that2: HTMLElement = this; // fails, type mismatch
const datum: CircleDatum = d;
const index: number = i;
const group: SVGCircleElement[] | ArrayLike = g;
console.log(this.r.baseVal.value); // this type is SVGCircleElement
return interpolateString(0, d.r); // datum type is CircleDatum
});
// test interpolateNumber(a, b) signature ----------------------------------------------------
iNum = d3Interpolate.interpolateNumber(0, 100);
iNum = d3Interpolate.interpolateNumber(new NumCoercible(0), new NumCoercible(100));
num = iNum(0.5);
// test interpolateNumber(a, b) signature ----------------------------------------------------
iNum = d3Interpolate.interpolateRound(0, 100);
iNum = d3Interpolate.interpolateRound(new NumCoercible(0), new NumCoercible(100));
num = iNum(0.5);
// test interpolateString(a, b) signature ----------------------------------------------------
iString = d3Interpolate.interpolateString('-1', '2');
str = iString(0.5);
// test interpolateDate(a, b) signature ----------------------------------------------------
iDate = d3Interpolate.interpolateDate(new Date(2016, 6, 1), new Date(2016, 6, 31));
// test interpolateArray(a, b) signature ----------------------------------------------------
iArrayNum = d3Interpolate.interpolateArray>([1, 2], [4, 8]); // explicit typing
arrNum = iArrayNum(0.5);
iArrayNum = d3Interpolate.interpolateArray<[number, number]>(['1', '2'], [4, 8]); // explicit typing
arrNum = iArrayNum(0.5);
iArrayStr = d3Interpolate.interpolateArray>(['1', '2'], ['4', '8']); // explicit typing
arrStr = iArrayStr(0.5);
// test interpolateNumber(a, b) signature ----------------------------------------------------
iNum = d3Interpolate.interpolateNumber(0, 100);
iNum = d3Interpolate.interpolateNumber(new NumCoercible(0), new NumCoercible(100));
num = iNum(0.5);
// test interpolateNumber(a, b) signature ----------------------------------------------------
iNum = d3Interpolate.interpolateRound(0, 100);
iNum = d3Interpolate.interpolateRound(new NumCoercible(0), new NumCoercible(100));
num = iNum(0.5);
// test interpolateString(a, b) signature ----------------------------------------------------
iString = d3Interpolate.interpolateString('-1', '2');
str = iString(0.5);
// test interpolateDate(a, b) signature ----------------------------------------------------
iDate = d3Interpolate.interpolateDate(new Date(2016, 6, 1), new Date(2016, 6, 31));
// test interpolateArray(a, b) signature ----------------------------------------------------
iArrayNum = d3Interpolate.interpolateArray([1, 2], [4, 8]); // explicit typing
arrNum = iArrayNum(0.5);
iArrayNum = d3Interpolate.interpolateArray<[number, number]>(['1', '2'], [4, 8]); // explicit typing
arrNum = iArrayNum(0.5);
iArrayStr = d3Interpolate.interpolateArray(['1', '2'], ['4', '8']); // explicit typing
arrStr = iArrayStr(0.5);
var tweenDash = function() {
var l = this.getTotalLength();
var i = d3interpolate.interpolateString("0," + l, l + "," + l);
return function(t) {
return i(t);
};
};
isUpating({node: {path}, duration}, {node}) {
node.setAttribute('opacity', 0.8);
let interp = interpolateString(node.getAttribute('d'), path);
this.transition = timer(elapsed => {
let t = elapsed < duration ? (elapsed / duration): 1;
node.setAttribute('d', interp(t));
if (t === 1) {
this.transition.stop();
}
});
}