Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
isEntering({xScale0, xScale1, tick: {data}, duration}, {tick}) {
let beg = `translate(${xScale0(data)},0)`;
let end = `translate(${xScale1(data)},0)`;
let interp0 = interpolateTransformSvg(beg, end);
let interp1 = interpolateNumber(1e-6, 1);
this.transition = timer(elapsed => {
let t = elapsed < duration ? (elapsed / duration): 1;
tick.setAttribute('transform', interp0(t));
tick.setAttribute('opacity', interp1(t));
if (t === 1) {
this.transition.stop();
}
});
}
onAppear({ prevXScale, currXScale, node: { data }, duration }) {
const beg = `translate(${prevXScale(data)},0)`;
const end = `translate(${currXScale(data)},0)`;
const interp0 = interpolateTransformSvg(beg, end);
const interp1 = interpolateNumber(1e-6, 1);
this.transition = timer((elapsed) => {
const t = elapsed < duration ? (elapsed / duration) : 1;
this.tick.setAttribute('transform', interp0(t));
this.tick.setAttribute('opacity', interp1(t));
if (t === 1) {
this.transition.stop();
}
});
}
isUpating({xScale0, xScale1, tick: {data}, duration}, {tick}) {
let beg = `translate(${xScale0(data)},0)`;
let end = `translate(${xScale1(data)},0)`;
let interp0 = interpolateTransformSvg(beg, end);
let interp1 = interpolateNumber(tick.getAttribute('opacity'), 1);
this.transition = timer(elapsed => {
let t = elapsed < duration ? (elapsed / duration): 1;
tick.setAttribute('transform', interp0(t));
tick.setAttribute('opacity', interp1(t));
if (t === 1) {
this.transition.stop();
}
});
}
onAppear({ yScale, node: { xVal, yVal }, duration }) {
this.rect.setAttribute('width', xVal);
this.rect.setAttribute('height', yScale.bandwidth());
this.text.setAttribute('x', xVal - 3);
const interp0 = interpolateTransformSvg('translate(0,500)', `translate(0,${yVal})`);
const interp1 = interpolateNumber(1e-6, 1);
this.transition = timer((elapsed) => {
const t = elapsed < duration ? (elapsed / duration) : 1;
this.node.setAttribute('transform', interp0(t));
this.node.setAttribute('opacity', interp1(t));
if (t === 1) {
this.transition.stop();
}
});
}
interpolation={(begValue, endValue, attr) => {
if (attr === 'transform') {
return interpolateTransformSvg(begValue, endValue)
}
return interpolate(begValue, endValue)
}}
isUpating({yScale, node: {xVal, yVal}, duration}, next, {node, rect, text}) {
let interp0 = interpolateTransformSvg(`translate(0,${yVal})`, `translate(0,${next.node.yVal})`);
let begVals = {w: xVal, h: yScale.bandwidth(), x: xVal - 3};
let endVals = {w: next.node.xVal, h: next.yScale.bandwidth(), x: next.node.xVal - 3};
let interp1 = interpolateObject(begVals, endVals);
node.setAttribute('opacity', 1);
this.transition = timer(elapsed => {
let t = elapsed < duration ? (elapsed / duration): 1;
node.setAttribute('transform', interp0(t));
let {w, h, x} = interp1(t);
rect.setAttribute('width', w);
rect.setAttribute('height', h);
text.setAttribute('x', x);
if (t === 1) {
isEntering({ yScale, node: { xVal, yVal }, duration }, { node, rect, text }) {
rect.setAttribute('width', xVal);
rect.setAttribute('height', yScale.bandwidth());
text.setAttribute('x', xVal - 3);
const interp0 = interpolateTransformSvg('translate(0,500)', `translate(0,${yVal})`);
const interp1 = interpolateNumber(1e-6, 1);
this.transition = timer((elapsed) => {
const t = elapsed < duration ? (elapsed / duration) : 1;
node.setAttribute('transform', interp0(t));
node.setAttribute('opacity', interp1(t));
if (t === 1) {
this.transition.stop();
}
});
}
isExiting({xScale0, xScale1, tick: {udid, data}, removeTick, duration}, {tick}) {
let beg = `translate(${xScale0(data)},0)`;
let end = `translate(${xScale1(data)},0)`;
let interp0 = interpolateTransformSvg(beg, end);
let interp1 = interpolateNumber(tick.getAttribute('opacity'), 1e-6);
this.transition = timer(elapsed => {
let t = elapsed < duration ? (elapsed / duration): 1;
tick.setAttribute('transform', interp0(t));
tick.setAttribute('opacity', interp1(t));
if (t === 1) {
this.transition.stop();
removeTick(udid);
}
});
}
isExiting({ node: { yVal, udid }, removeNode, duration }, { node }) {
const interp0 = interpolateTransformSvg(`translate(0,${yVal})`, 'translate(0,500)');
const interp1 = interpolateNumber(1, 1e-6);
this.transition = timer((elapsed) => {
const t = elapsed < duration ? (elapsed / duration) : 1;
node.setAttribute('transform', interp0(t));
node.setAttribute('opacity', interp1(t));
if (t === 1) {
this.transition.stop();
removeNode(udid);
}
});
}
isEntering({xScale0, xScale1, tick: {data}, duration}, {tick}) {
let beg = `translate(${xScale0(data)},0)`;
let end = `translate(${xScale1(data)},0)`;
let interp0 = interpolateTransformSvg(beg, end);
let interp1 = interpolateNumber(1e-6, 1);
this.transition = timer(elapsed => {
let t = elapsed < duration ? (elapsed / duration): 1;
tick.setAttribute('transform', interp0(t));
tick.setAttribute('opacity', interp1(t));
if (t === 1) {
this.transition.stop();
}
});
}