UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

44 lines 1.84 kB
import { Surface } from "@aurigma/design-atoms-model/Product"; import { NotImplementedException } from "@aurigma/design-atoms-model/Exception"; var SnapshotHandler = /** @class */ (function () { function SnapshotHandler(_viewer) { this._viewer = _viewer; } Object.defineProperty(SnapshotHandler.prototype, "_product", { get: function () { return this._surface != null ? this._surface.parentProduct : null; }, enumerable: true, configurable: true }); Object.defineProperty(SnapshotHandler.prototype, "_surface", { get: function () { return this._viewer.surface; }, enumerable: true, configurable: true }); SnapshotHandler.prototype.createSnapshot = function () { var snapshotObject = this._product != null ? this._product : this._surface; if (snapshotObject == null) return; return snapshotObject.clone(); }; SnapshotHandler.prototype.loadSnapshot = function (originalSnapshot) { var _a; var eventManager = this._viewer.eventManager; var snapshot = originalSnapshot.clone(); eventManager.beforeSnapshotLoad.fire(snapshot); if (snapshot instanceof Surface) { throw new NotImplementedException("Surface as snapshot not implemented!"); } else { var oldSurfaceId_1 = this._surface.id; this._viewer.surface = (_a = snapshot.surfaces.firstOrDefault(function (s) { return s.id === oldSurfaceId_1; })) !== null && _a !== void 0 ? _a : snapshot.surfaces.get(0); eventManager.snapshotLoadedEvent.fire(snapshot); } }; return SnapshotHandler; }()); export { SnapshotHandler }; //# sourceMappingURL=SnapshotHandler.js.map