@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
34 lines • 1.35 kB
JavaScript
import { Surface } from "@aurigma/design-atoms-model/Product";
import { NotImplementedException } from "@aurigma/design-atoms-model/Exception";
export class SnapshotHandler {
constructor(_viewer) {
this._viewer = _viewer;
}
get _product() {
return this._surface != null ? this._surface.parentProduct : null;
}
get _surface() {
return this._viewer.surface;
}
createSnapshot() {
const snapshotObject = this._product != null ? this._product : this._surface;
if (snapshotObject == null)
return;
return snapshotObject.clone();
}
loadSnapshot(originalSnapshot) {
var _a;
const eventManager = this._viewer.eventManager;
const snapshot = originalSnapshot.clone();
eventManager.beforeSnapshotLoad.fire(snapshot);
if (snapshot instanceof Surface) {
throw new NotImplementedException("Surface as snapshot not implemented!");
}
else {
const oldSurfaceId = this._surface.id;
this._viewer.surface = (_a = snapshot.surfaces.firstOrDefault(s => s.id === oldSurfaceId)) !== null && _a !== void 0 ? _a : snapshot.surfaces.get(0);
eventManager.snapshotLoadedEvent.fire(snapshot);
}
}
}
//# sourceMappingURL=SnapshotHandler.js.map