Я пытаюсь воспроизвести анимацию высоты, которая доступна в этом репо:
https://github.com/alexziskind1/tnsheightanimationdemo
Вот мой компонент:
import { Component } from "@angular/core";
import { Observable, Scheduler } from "rxjs";
import { Label } from 'ui/label';
import 'rxjs/observable/defer'
import 'rxjs/scheduler/animationFrame';
import 'rxjs/observable/interval'
const timeElapsed = Observable.defer(() => {
const start = Scheduler.animationFrame.now();
return Observable.interval(1)
.map(() => Math.floor((Date.now() - Date.now())));
});
const duration = (totalMs) =>
timeElapsed
.map(elapsedMs => elapsedMs / totalMs)
.takeWhile(t => t <= 1);
const amount = (d) => (t) => t * d;
const elasticOut = (t) =>
Math.sin(-13.0 * (t + 1.0) *
Math.PI / 2) *
Math.pow(2.0, -10.0 * t) +
1.0;
@Component({
selector: "ns-app",
template: `
<StackLayout class="wrapper" (tap)="onTap($event)">
<Label class="thelabel1" text="Hello" [height]="blah$ | async"></Label>
<Label class="thelabel2" text="Hello" [height]="blah$ | async"></Label>
</StackLayout>
`,
styles: [
`
`
})
export class TestComponent {
blah$: Observable<number> = Observable.of(25);
onTap() {
this.blah$ = duration(2000)
.map(elasticOut)
.map(amount(150));
}
}
Как только приложение выполнено, я получил следующее сообщение об ошибке:
TypeError: document.createElement не является функцией
Файл: "file: ///data/data/org.nativescript.PocDigitalLab/files/app/tns_modules/rxjs/util/Immediate.js, строка: 56, столбец: 68.
Любая помощь очень ценится.