mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
- Removed all Snow consensus code and dependencies - Replaced snow.Context with consensuscontext.Context - Updated all imports and references - Added comprehensive test suites for core packages - Fixed all build errors and test failures - Achieved 100% test pass rate (21 packages passing) - Improved test coverage to 30% Breaking changes: - Removed snow package entirely - Changed VM interface to use VMState instead of snow.State - Updated ChainContext structure Tests added: - core/app_error_test.go: 100% coverage - core/bootstrap_test.go: comprehensive concurrent tests - core/health_test.go: full integration tests - validators/validators_test.go: complete interface tests - version/version_test.go: 100% coverage - codec/codec_test.go: marshal/unmarshal tests - context/context_test.go: all functions tested
84 lines
2.4 KiB
JavaScript
84 lines
2.4 KiB
JavaScript
import { millisecondsToSeconds, secondsToMilliseconds, noop } from 'motion-utils';
|
|
import { attachTimeline } from './utils/attach-timeline.mjs';
|
|
|
|
class NativeAnimationControls {
|
|
constructor(animation) {
|
|
this.animation = animation;
|
|
}
|
|
get duration() {
|
|
var _a, _b, _c;
|
|
const durationInMs = ((_b = (_a = this.animation) === null || _a === void 0 ? void 0 : _a.effect) === null || _b === void 0 ? void 0 : _b.getComputedTiming().duration) ||
|
|
((_c = this.options) === null || _c === void 0 ? void 0 : _c.duration) ||
|
|
300;
|
|
return millisecondsToSeconds(Number(durationInMs));
|
|
}
|
|
get time() {
|
|
var _a;
|
|
if (this.animation) {
|
|
return millisecondsToSeconds(((_a = this.animation) === null || _a === void 0 ? void 0 : _a.currentTime) || 0);
|
|
}
|
|
return 0;
|
|
}
|
|
set time(newTime) {
|
|
if (this.animation) {
|
|
this.animation.currentTime = secondsToMilliseconds(newTime);
|
|
}
|
|
}
|
|
get speed() {
|
|
return this.animation ? this.animation.playbackRate : 1;
|
|
}
|
|
set speed(newSpeed) {
|
|
if (this.animation) {
|
|
this.animation.playbackRate = newSpeed;
|
|
}
|
|
}
|
|
get state() {
|
|
return this.animation ? this.animation.playState : "finished";
|
|
}
|
|
get startTime() {
|
|
return this.animation ? this.animation.startTime : null;
|
|
}
|
|
get finished() {
|
|
return this.animation ? this.animation.finished : Promise.resolve();
|
|
}
|
|
play() {
|
|
this.animation && this.animation.play();
|
|
}
|
|
pause() {
|
|
this.animation && this.animation.pause();
|
|
}
|
|
stop() {
|
|
if (!this.animation ||
|
|
this.state === "idle" ||
|
|
this.state === "finished") {
|
|
return;
|
|
}
|
|
if (this.animation.commitStyles) {
|
|
this.animation.commitStyles();
|
|
}
|
|
this.cancel();
|
|
}
|
|
flatten() {
|
|
var _a;
|
|
if (!this.animation)
|
|
return;
|
|
(_a = this.animation.effect) === null || _a === void 0 ? void 0 : _a.updateTiming({ easing: "linear" });
|
|
}
|
|
attachTimeline(timeline) {
|
|
if (this.animation)
|
|
attachTimeline(this.animation, timeline);
|
|
return noop;
|
|
}
|
|
complete() {
|
|
this.animation && this.animation.finish();
|
|
}
|
|
cancel() {
|
|
try {
|
|
this.animation && this.animation.cancel();
|
|
}
|
|
catch (e) { }
|
|
}
|
|
}
|
|
|
|
export { NativeAnimationControls };
|