atr-components 0.2.306 → 0.2.308

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,48 @@ class ToolsUtil {
326
330
  }
327
331
  return false;
328
332
  }
333
+ //判断点是否在线段上
334
+ static checkInLine(startP, endP, a) {
335
+ //点和端点重合
336
+ if ((startP.x == endP.x && startP.y == endP.y)
337
+ || (startP.x == a.x && startP.y == a.y)
338
+ || (endP.x == a.x && endP.y == a.y)) {
339
+ return true;
340
+ }
341
+ if (startP.x == endP.x && endP.x != a.x) {
342
+ return false;
343
+ }
344
+ else if (startP.x == endP.x && endP.x == a.x) {
345
+ if (startP.y > endP.y) {
346
+ return startP.y > a.y && endP.y < a.y;
347
+ }
348
+ return startP.y < a.y && endP.y < a.y;
349
+ }
350
+ //判断点在线段上
351
+ //斜率是否一致
352
+ let k1 = (endP.y - startP.y) / (endP.x - startP.x);
353
+ let b = startP.y - k1 * startP.x;
354
+ //y = kx + y1 - kx1
355
+ //b = y1 - kx1
356
+ let y = k1 * a.x + b, num = y - a.y;
357
+ if (num > -5 && num < 5) {
358
+ //5像素的误差
359
+ let startLen = ToolsUtil.getLength(startP, a);
360
+ let endLen = ToolsUtil.getLength(a, endP);
361
+ let len = ToolsUtil.getLength(startP, endP);
362
+ return len >= startLen && len >= endLen;
363
+ }
364
+ // let k2 = (a.y - startP.y) / (a.x - startP.x);
365
+ // //Number.EPSILON是精度误差
366
+ // if (Math.abs(k1 - k2) <= Number.EPSILON) {
367
+ // //斜率一致,并且a在线段上
368
+ // let startLen = ToolsUtil.getLength(startP, a)
369
+ // let endLen = ToolsUtil.getLength(a, endP)
370
+ // let leng = ToolsUtil.getLength(startP, endP)
371
+ // return leng >= startLen && leng >= endLen
372
+ // }
373
+ return false;
374
+ }
329
375
  /**
330
376
  *判断点是否在坐标区域内
331
377
  * @param p 判定的点
@@ -696,11 +742,21 @@ class ToolsUtil {
696
742
  return { 'maxHeight': ToolsUtil.windowHeight() - 200 + 'px', 'overflow-y': 'auto' };
697
743
  }
698
744
  static getLength(pointA, pointB) {
745
+ pointA.x1 = pointA.x || pointA.x1;
746
+ pointA.y1 = pointA.y || pointA.y1;
747
+ pointB.y1 = pointB.y || pointB.y1;
748
+ pointB.x1 = pointB.x || pointB.x1;
699
749
  var lengthAB = Math.sqrt(Math.pow(pointA.x1 - pointB.x1, 2) +
700
750
  Math.pow(pointA.y1 - pointB.y1, 2));
701
751
  return lengthAB;
702
752
  }
703
753
  static getRotateNum(pointB, pointC, pointA) {
754
+ pointA.x1 = pointA.x || pointA.x1;
755
+ pointA.y1 = pointA.y || pointA.y1;
756
+ pointB.x1 = pointB.y || pointB.x1;
757
+ pointB.y1 = pointB.x || pointB.x1;
758
+ pointC.x1 = pointC.y || pointC.x1;
759
+ pointC.y1 = pointC.x || pointC.x1;
704
760
  //ABC中心点,起始点,终点
705
761
  let AB = {};
706
762
  let AC = {};