canvas-editor-engine 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  import ComponentService from "../services/component.service";
2
- import type { IExcretionsCoords, TExcretionToolState } from "../types/excretion";
2
+ import type { IExcretionsCoords, TExcretionStyle, TExcretionToolState } from "../types/excretion";
3
3
  export default class ExcretionsComponent extends ComponentService {
4
4
  private static template;
5
5
  private static css;
@@ -10,6 +10,10 @@ export default class ExcretionsComponent extends ComponentService {
10
10
  private static _excretionToolState;
11
11
  private static _tempCoords;
12
12
  static excretionsCoords: IExcretionsCoords[];
13
+ private static _style;
14
+ static get style(): TExcretionStyle;
15
+ static set style(value: TExcretionStyle);
16
+ private static applyExcretionStyle;
13
17
  private static tool;
14
18
  static getComponent(): {
15
19
  excretionsTemplate: HTMLElement;
@@ -5,6 +5,34 @@ const tool_service_1 = require("../services/tool.service");
5
5
  const canvas_component_1 = require("./canvas.component");
6
6
  const logger_service_1 = require("../services/logger.service");
7
7
  class ExcretionsComponent extends component_service_1.default {
8
+ static get style() {
9
+ return ExcretionsComponent._style;
10
+ }
11
+ static set style(value) {
12
+ ExcretionsComponent._style = value;
13
+ ExcretionsComponent.applyExcretionStyle();
14
+ }
15
+ static applyExcretionStyle() {
16
+ if (ExcretionsComponent._style === 'crop') {
17
+ ExcretionsComponent._excretions.forEach((excretion) => {
18
+ if (!!excretion) {
19
+ if (!excretion.classList.contains('excretion_crop')) {
20
+ excretion.classList.add("excretion_crop");
21
+ }
22
+ }
23
+ });
24
+ }
25
+ else {
26
+ ExcretionsComponent._excretions.forEach((excretion) => {
27
+ if (!!excretion) {
28
+ if (excretion.classList.contains('excretion_crop')) {
29
+ excretion.classList.remove("excretion_crop");
30
+ }
31
+ }
32
+ });
33
+ }
34
+ }
35
+ ;
8
36
  static getComponent() {
9
37
  const wrapOptions = {
10
38
  className: 'excretions-wrap',
@@ -17,6 +45,7 @@ class ExcretionsComponent extends component_service_1.default {
17
45
  }
18
46
  static set excretionState(state) {
19
47
  ExcretionsComponent._excretionState = state;
48
+ ExcretionsComponent.applyExcretionStyle();
20
49
  switch (state) {
21
50
  case 'abandoned':
22
51
  canvas_component_1.default.cursorStyle = 'default';
@@ -97,6 +126,7 @@ class ExcretionsComponent extends component_service_1.default {
97
126
  };
98
127
  ExcretionsComponent._tempCoords.push(tempStart);
99
128
  }
129
+ ExcretionsComponent.applyExcretionStyle();
100
130
  ExcretionsComponent._excretionActivity = 'active';
101
131
  });
102
132
  canvas_component_1.default.subscribe('mousemove', (event, cursorPosition) => {
@@ -165,6 +195,10 @@ ExcretionsComponent.css = `
165
195
  animation: border-dance 1s infinite linear;
166
196
  }
167
197
 
198
+ .excretion_crop {
199
+ box-shadow: 0px 0px 0px 100% rgba(34, 60, 80, 0.2);
200
+ }
201
+
168
202
  @keyframes border-dance {
169
203
  0% {
170
204
  background-position: left top, right bottom, left bottom, right top;
@@ -180,6 +214,7 @@ ExcretionsComponent._excretionActivity = 'abandoned';
180
214
  ExcretionsComponent._excretionToolState = 'abandoned';
181
215
  ExcretionsComponent._tempCoords = [];
182
216
  ExcretionsComponent.excretionsCoords = [];
217
+ ExcretionsComponent._style = 'default';
183
218
  ExcretionsComponent.tool = {
184
219
  id: 1,
185
220
  name: 'excretion',
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import SlotComponent from "./components/slot.component";
7
7
  import DrawService from "./services/draw.service";
8
8
  import ToolService from "./services/tool.service";
9
9
  import LoggerService from "./services/logger.service";
10
+ import CropService from "./services/crop.service";
10
11
  declare class CanvasEditorEngine {
11
12
  constructor(webComponentTagName?: string);
12
13
  getInitial(): {
@@ -23,4 +24,4 @@ declare class VueCanvasEditorEngine extends CanvasEditorEngine {
23
24
  getContext2D(): CanvasRenderingContext2D;
24
25
  getCanvas(): HTMLCanvasElement;
25
26
  }
26
- export { AppConfig, PipetteComponent, CanvasComponent, ExcretionComponent, SlotComponent, ToolService, DrawService, LoggerService, StaticCanvasEditorEngine, VueCanvasEditorEngine, };
27
+ export { AppConfig, PipetteComponent, CanvasComponent, ExcretionComponent, SlotComponent, ToolService, DrawService, LoggerService, CropService, StaticCanvasEditorEngine, VueCanvasEditorEngine, };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VueCanvasEditorEngine = exports.StaticCanvasEditorEngine = exports.LoggerService = exports.DrawService = exports.ToolService = exports.SlotComponent = exports.ExcretionComponent = exports.CanvasComponent = exports.PipetteComponent = exports.AppConfig = void 0;
3
+ exports.VueCanvasEditorEngine = exports.StaticCanvasEditorEngine = exports.CropService = exports.LoggerService = exports.DrawService = exports.ToolService = exports.SlotComponent = exports.ExcretionComponent = exports.CanvasComponent = exports.PipetteComponent = exports.AppConfig = void 0;
4
4
  const config_1 = require("./config");
5
5
  exports.AppConfig = config_1.default;
6
6
  const web_component_1 = require("./web-component");
@@ -18,6 +18,8 @@ const tool_service_1 = require("./services/tool.service");
18
18
  exports.ToolService = tool_service_1.default;
19
19
  const logger_service_1 = require("./services/logger.service");
20
20
  exports.LoggerService = logger_service_1.default;
21
+ const crop_service_1 = require("./services/crop.service");
22
+ exports.CropService = crop_service_1.default;
21
23
  class CanvasEditorEngine {
22
24
  constructor(webComponentTagName) {
23
25
  config_1.default.WEB_COMPONENT_TAG_NAME = webComponentTagName;
@@ -0,0 +1,3 @@
1
+ export default class CropService {
2
+ static crop(): void;
3
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const excretions_component_1 = require("../components/excretions.component");
4
+ class CropService {
5
+ static crop() {
6
+ excretions_component_1.default.style = 'crop';
7
+ console.log('ExcretionComponent.excretionsCoords', excretions_component_1.default.excretionsCoords);
8
+ }
9
+ }
10
+ exports.default = CropService;
@@ -24,3 +24,4 @@ export type TExcretionTempCoords = (IExcretionTempStart | IExcretionTempEnd)[];
24
24
  export type TExcretionToolState = 'taken' | 'abandoned';
25
25
  export type TExcretionState = 'create' | 'add' | 'remove' | 'abandoned';
26
26
  export type TExcretionActivity = 'active' | 'end' | 'abandoned';
27
+ export type TExcretionStyle = 'default' | 'crop';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-editor-engine",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",