magnitude-core
Version:
Magnitude e2e testing agent
48 lines (47 loc) • 1.52 kB
JavaScript
import { CursorVisual } from "./cursor";
import { MouseEffectVisual } from "./mouseEffects";
import { TypeEffectVisual } from "./typeEffects";
export class ActionVisualizer {
options;
context;
page;
cursor;
mouseEffects;
typeEffects;
constructor(context, options) {
this.context = context;
this.options = {
showCursor: options.showCursor ?? true,
showHoverCircle: options.showHoverCircle ?? false,
showClickRipple: options.showClickRipple ?? true,
showDragLine: options.showDragLine ?? false,
showTypeEffects: options.showTypeEffects ?? true
};
this.cursor = new CursorVisual();
this.mouseEffects = new MouseEffectVisual(this.options);
this.typeEffects = new TypeEffectVisual();
}
async setup() {
// await this.mouseEffects.setContext(this.context);
// if (this.options.showTypeEffects) {
// await this.typeEffects.setContext(this.context);
// }
//this.showAll();
}
async setActivePage(page) {
this.page = page;
await this.cursor.setActivePage(page);
await this.mouseEffects.setActivePage(page);
await this.typeEffects.setActivePage(page);
}
async moveVirtualCursor(x, y) {
// Takes like 300ms for smooth anim
await this.cursor.move(x, y);
}
async hideAll() {
await this.cursor.hide();
}
async showAll() {
await this.cursor.show();
}
}