atr-components 0.2.306 → 0.2.309

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,7 @@ import * as i2$3 from 'ng-zorro-antd/message';
12
12
  import { NzMessageService, NzMessageModule } from 'ng-zorro-antd/message';
13
13
  import * as i3$1 from '@angular/forms';
14
14
  import { Validators, FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR, FormControl } from '@angular/forms';
15
+ import { ulid } from 'ulid';
15
16
  import { NzAffixModule } from 'ng-zorro-antd/affix';
16
17
  import { NzAlertModule } from 'ng-zorro-antd/alert';
17
18
  import { NzAnchorModule } from 'ng-zorro-antd/anchor';
@@ -245,6 +246,9 @@ class SessionStorageUtil {
245
246
  }
246
247
 
247
248
  class ToolsUtil {
249
+ static getUlid() {
250
+ return ulid();
251
+ }
248
252
  static isBase64(string) {
249
253
  let reg = /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i;
250
254
  return reg.test(string);
@@ -326,6 +330,65 @@ class ToolsUtil {
326
330
  }
327
331
  return false;
328
332
  }
333
+ /**
334
+ *
335
+ * @param num1
336
+ * @param num2
337
+ * @param error 误差
338
+ */
339
+ static equalNum(num1, num2, error = 5) {
340
+ let num = num1 - num2;
341
+ return num < error && num > -error;
342
+ }
343
+ /**
344
+ * 坐标对比
345
+ * @param point1
346
+ * @param point2
347
+ * @param error
348
+ */
349
+ static equalPoint(point1, point2, error = 5) {
350
+ return ToolsUtil.equalNum(point1.x, point2.x, error) && ToolsUtil.equalNum(point1.y, point2.y, error);
351
+ }
352
+ //判断点是否在线段上
353
+ /**
354
+ *
355
+ * @param startP
356
+ * @param endP
357
+ * @param a
358
+ * @param error 误差
359
+ */
360
+ static checkInLine(startP, endP, a, error = 5) {
361
+ //点和端点重合
362
+ if (ToolsUtil.equalPoint(startP, endP, error)
363
+ || ToolsUtil.equalPoint(startP, a)
364
+ || ToolsUtil.equalPoint(endP, a)) {
365
+ return true;
366
+ }
367
+ if (ToolsUtil.equalNum(startP.x, endP.x, error)
368
+ && !ToolsUtil.equalNum(startP.x, a.x, error)) {
369
+ return false;
370
+ }
371
+ else if (ToolsUtil.equalNum(startP.x, endP.x, error)
372
+ && ToolsUtil.equalNum(startP.x, a.x, error)) {
373
+ if (startP.y > endP.y) {
374
+ return startP.y > a.y && endP.y < a.y;
375
+ }
376
+ return startP.y < a.y && endP.y > a.y;
377
+ }
378
+ //判断点在线段上
379
+ //斜率是否一致
380
+ let k1 = (endP.y - startP.y) / (endP.x - startP.x);
381
+ let b = startP.y - k1 * startP.x;
382
+ let y = k1 * a.x + b;
383
+ if (ToolsUtil.equalNum(y, a.y, error)) {
384
+ //5像素的误差
385
+ let startLen = ToolsUtil.getLength(startP, a);
386
+ let endLen = ToolsUtil.getLength(a, endP);
387
+ let len = ToolsUtil.getLength(startP, endP);
388
+ return len >= startLen && len >= endLen;
389
+ }
390
+ return false;
391
+ }
329
392
  /**
330
393
  *判断点是否在坐标区域内
331
394
  * @param p 判定的点
@@ -696,11 +759,21 @@ class ToolsUtil {
696
759
  return { 'maxHeight': ToolsUtil.windowHeight() - 200 + 'px', 'overflow-y': 'auto' };
697
760
  }
698
761
  static getLength(pointA, pointB) {
762
+ pointA.x1 = pointA.x || pointA.x1 || 0;
763
+ pointA.y1 = pointA.y || pointA.y1 || 0;
764
+ pointB.y1 = pointB.y || pointB.y1 || 0;
765
+ pointB.x1 = pointB.x || pointB.x1 || 0;
699
766
  var lengthAB = Math.sqrt(Math.pow(pointA.x1 - pointB.x1, 2) +
700
767
  Math.pow(pointA.y1 - pointB.y1, 2));
701
768
  return lengthAB;
702
769
  }
703
770
  static getRotateNum(pointB, pointC, pointA) {
771
+ pointA.x1 = pointA.x || pointA.x1 || 0;
772
+ pointA.y1 = pointA.y || pointA.y1 || 0;
773
+ pointB.x1 = pointB.y || pointB.x1 || 0;
774
+ pointB.y1 = pointB.x || pointB.x1 || 0;
775
+ pointC.x1 = pointC.y || pointC.x1 || 0;
776
+ pointC.y1 = pointC.x || pointC.x1 || 0;
704
777
  //ABC中心点,起始点,终点
705
778
  let AB = {};
706
779
  let AC = {};