@nativescript-community/ui-chart
Version:
A powerful chart / graph plugin, supporting line, bar, pie, radar, bubble, and candlestick charts as well as scaling, panning and animations.
42 lines • 1.7 kB
JavaScript
import { ObjectPool } from '../utils/ObjectPool';
import { Utils } from '../utils/Utils';
import { AnimatedViewPortJob } from './AnimatedViewPortJob';
/**
* Created by Philipp Jahoda on 19/02/16.
*/
export class AnimatedMoveViewJob extends AnimatedViewPortJob {
static getInstance(viewPortHandler, xValue, yValue, trans, v, xOrigin, yOrigin, duration) {
const result = pool.get();
result.mViewPortHandler = viewPortHandler;
result.xValue = xValue;
result.yValue = yValue;
result.transformer = trans;
result.mView = v;
result.xOrigin = xOrigin;
result.yOrigin = yOrigin;
//result.resetAnimator();
result.createAnimator(duration);
return result;
}
static recycleInstance(instance) {
pool.recycle(instance);
}
constructor(viewPortHandler, xValue, yValue, trans, v, xOrigin, yOrigin, duration) {
super(viewPortHandler, xValue, yValue, trans, v, xOrigin, yOrigin, duration);
}
onAnimationUpdate(animation) {
const pts = Utils.getTempArray(2);
pts[0] = this.xOrigin + (this.xValue - this.xOrigin) * this.phase;
pts[1] = this.yOrigin + (this.yValue - this.yOrigin) * this.phase;
this.transformer.pointValuesToPixel(pts);
this.mViewPortHandler.centerViewPort(pts, this.mView);
}
recycleSelf() {
AnimatedMoveViewJob.recycleInstance(this);
}
instantiate() {
return new AnimatedMoveViewJob(null, 0, 0, null, null, 0, 0, 0);
}
}
const pool = ObjectPool.create(4, new AnimatedMoveViewJob(null, 0, 0, null, null, 0, 0, 0)).setReplenishPercentage(0.5);
//# sourceMappingURL=AnimatedMoveViewJob.js.map