htui-yllkbz 1.3.24 → 1.3.25

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "htui-yllkbz",
3
- "version": "1.3.24",
3
+ "version": "1.3.25",
4
+ "port": "8082",
4
5
  "typings": "types/index.d.ts",
5
6
  "main": "lib/htui.common.js",
6
7
  "style": "lib/htui.css",
@@ -23,9 +24,10 @@
23
24
  "core-js": "^3.6.5",
24
25
  "element-ui": "^2.14.1",
25
26
  "html2canvas": "1.0.0-rc.1",
26
- "htui-yllkbz": "^1.3.23",
27
+ "htui-yllkbz": "^1.3.24",
27
28
  "mavon-editor": "^2.10.4",
28
29
  "moment": "^2.29.1",
30
+ "oidc-client": "^1.11.5",
29
31
  "vue": "^2.6.11",
30
32
  "vue-class-component": "^7.2.3",
31
33
  "vue-kst-auth": "^2.1.15",
package/src/App.vue CHANGED
@@ -4,36 +4,36 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-11-15 14:41:40
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2021-12-21 17:25:49
7
+ * @LastEditTime: 2022-05-10 10:39:13
8
8
  -->
9
9
  <template>
10
10
  <div id="app">
11
- <SelectTable :columns="[]"
12
- :config="JSON.stringify({
13
- key: 'code',
14
- disabled:false,
15
- clearable:true,
16
- value:undefined,
17
- name:'id',
18
- ajax:{
19
- type:'get',
20
- url: '/asset-model/api/app/asset-model-instance',
21
- },
22
- text:'name',
23
- })"></SelectTable>
24
-
11
+ <el-button type=""
12
+ @click="test">测试</el-button>
13
+ <HtSelectBaseData dataTypeId="chengbenzhongxin"
14
+ v-model="state.value"
15
+ @change="change"></HtSelectBaseData>
16
+ <HtSelectBaseData dataTypeId="positions"
17
+ :multiple="false"
18
+ v-model="state.value"
19
+ @change="change"></HtSelectBaseData>
25
20
  <router-view></router-view>
26
21
  </div>
27
22
  </template>
28
23
 
29
24
  <script lang="ts">
30
25
  import { Component, Vue } from "vue-property-decorator";
31
- import SelectTable from "@/packages/SelectTable/index.vue";
32
-
26
+ import HtSelectBaseData from "@/packages/HtSelectBaseData";
27
+ import { mgr } from "@/plugins/oidc-client";
33
28
  @Component({
34
- components: { SelectTable },
29
+ components: {
30
+ HtSelectBaseData,
31
+ },
35
32
  })
36
33
  export default class App extends Vue {
34
+ state = {
35
+ value: undefined,
36
+ };
37
37
  /** 生命周期 */
38
38
  created() {
39
39
  // 动态加载引用文件
@@ -51,6 +51,61 @@ export default class App extends Vue {
51
51
  });
52
52
  document.getElementsByTagName("head")[0].innerHTML = heatStr;
53
53
  }
54
+ change() {
55
+ // console.log("eeee", e);
56
+ }
57
+ test(e: any) {
58
+ //mgr.removeUser();
59
+ // mgr.events.
60
+ //console.log("eeee", mgr.getUser().then(res));
61
+ // mgr.getUser().then((res) => {
62
+ // console.log("eeee", res);
63
+ // });
64
+
65
+ e.preventDefault();
66
+ e.stopPropagation();
67
+
68
+ mgr.signoutRedirect();
69
+ // mgr.revokeAccessToken();
70
+ // mgr.signoutCallback(window.location.href, true).then((res) => {
71
+ // alert;
72
+ // console.log("rrres", res);
73
+ // //
74
+ // });
75
+ mgr.signinRedirect();
76
+ // mgr.signoutRedirectCallback().then(() => {
77
+ // mgr.getUser().then((user) => {
78
+ // console.log("user", user);
79
+ // });
80
+ // });
81
+ // console.log("ttt", tt, mgr.getUser());
82
+ // });
83
+ //mgr.signinSilent();
84
+ // mgr.removeUser().then((res) => {
85
+ // console.log("rres", res);
86
+ // mgr.signinRedirect();
87
+ // });
88
+ // mgr.signoutRedirect(); //退出登录
89
+ //mgr.removeUser();
90
+ // mgr.signoutRedirectCallback().then((res) => {
91
+ // console.log("res", res);
92
+ // }); //登录
93
+ // mgr.getUser(); //获取用户信息
94
+ // mgr.signinRedirectCallback(); //callback
95
+ // mgr.revokeAccessToken();
96
+ //mgr.
97
+ //mgr.signoutPopup();
98
+ //mgr.signinPopup();
99
+ // mgr.signoutRedirectCallback(window.location.href).then((res) => {
100
+ // //window.location.href = window.location.href;
101
+ // console.log("res", res);
102
+ // // mgr.signinRedirect();
103
+ // });
104
+ // mgr.signoutRedirect();
105
+ //mgr.clearStaleState();
106
+ // mgr.signinRedirectCallback(window.location.href);
107
+ // mgr.signinRedirect();
108
+ }
54
109
  }
55
110
  </script>
56
111
 
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <div>
3
+
3
4
  <!-- 选择部门 -->
4
5
  <template v-if="
5
6
  state.configJson['departmentId'] &&
@@ -28,7 +29,7 @@
28
29
  }"
29
30
  @click.native="selectClick($event)"
30
31
  ref="departmentId"
31
- @change="setSelctData('departmentId')"
32
+ @change="setSelctData('departmentId',$event)"
32
33
  :options="organizationUsersTree">
33
34
  </el-cascader>
34
35
  <el-cascader-panel v-if="state.configJson['departmentId'].panel"
@@ -47,7 +48,7 @@
47
48
  multiple: state.configJson['departmentId'].multiple,
48
49
  }"
49
50
  ref="departmentId"
50
- @change="setSelctData('departmentId')"
51
+ @change="setSelctData('departmentId',$event)"
51
52
  :options="organizationUsersTree">
52
53
  <template slot-scope="{ data }">
53
54
  <span>{{ data.label }}</span>
@@ -116,7 +117,7 @@
116
117
  }"
117
118
  ref="departmentUser"
118
119
  @click.native="selectClick($event)"
119
- @change="setSelctData('departmentUser')"
120
+ @change="setSelctData('departmentUser',$event)"
120
121
  :options="organizationUsersTreeUser">
121
122
  <template slot-scope="{ data }">
122
123
  <p class="ht-user-dot"
@@ -163,7 +164,7 @@
163
164
  multiple: state.configJson['departmentUser'].multiple,
164
165
  }"
165
166
  ref="departmentUser"
166
- @change="setSelctData('departmentUser')"
167
+ @change="setSelctData('departmentUser',$event)"
167
168
  :options="organizationUsersTreeUser">
168
169
  <template slot-scope="{ data }">
169
170
  <p class="ht-user-dot"
@@ -281,10 +282,10 @@
281
282
  multiple: state.configJson[item.code].multiple,
282
283
  }"
283
284
  :ref="`${item.code}`"
284
- @change="setSelctData(item.code)"
285
+ @change="setSelctData(item.code,$event)"
285
286
  :options="getbaseDataInfo[item.id]"></el-cascader>
286
287
  <el-cascader-panel v-else
287
- @click.native="selectClick($event)"
288
+ @click.native="selectClick($event,)"
288
289
  :placeholder="`请选择${item.name}`"
289
290
  class="component-item"
290
291
  :key="item.id"
@@ -300,7 +301,7 @@
300
301
  multiple: state.configJson[item.code].multiple,
301
302
  }"
302
303
  :ref="`${item.code}`"
303
- @change="setSelctData(item.code)"
304
+ @change="setSelctData(item.code,$event)"
304
305
  :options="getbaseDataInfo[item.id]"></el-cascader-panel>
305
306
  </template>
306
307
  </template>
@@ -650,15 +651,27 @@ export default class CommonDatas extends Vue {
650
651
  // });
651
652
  }
652
653
  /** 设置下拉数据(级联选择) */
653
- setSelctData(key: string) {
654
+ setSelctData(key: string, e?: string) {
655
+ const value = e ? e : this.state.selectVal[key];
654
656
  const ref: any | undefined = (this.$refs[key] as any)[0] || this.$refs[key];
655
- const checkList = ref ? ref.getCheckedNodes() : [];
657
+
658
+ let checkList = [];
659
+ if (ref && ref.getCheckedNodes() && ref.getCheckedNodes()[0] !== null) {
660
+ checkList = ref.getCheckedNodes();
661
+ } else if (
662
+ ref &&
663
+ ref.getCheckedNodes() &&
664
+ ref.getCheckedNodes()[0] === null
665
+ ) {
666
+ checkList = [ref.panel.getNodeByValue(value)];
667
+ }
668
+
656
669
  /** 过滤在多选模式下,Tag时触发删除 */
657
670
  const checkNodes = checkList.filter((item: any) => {
658
- return this.state.selectVal[key]?.includes(item.data.id);
671
+ return value?.includes(item.data.id);
659
672
  });
660
- this.state.selectValData[key] = [];
661
673
  if (checkNodes && checkNodes.length && checkNodes[0] !== null) {
674
+ this.state.selectValData[key] = [];
662
675
  checkNodes.forEach(
663
676
  (item: { data?: { id: string; name: string } } | undefined) => {
664
677
  const { data } = item || { data: "" };
@@ -4,7 +4,7 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-10-21 10:08:41
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2022-04-29 16:52:52
7
+ * @LastEditTime: 2022-05-05 09:12:46
8
8
  */
9
9
 
10
10
  // 导入组件
@@ -25,12 +25,12 @@ import HtSelectUser from './HtSelectUser/index'
25
25
  import HtShowBaseData from './HtShowBaseData/index'
26
26
  import HtOrgInfo from './HtOrgInfo/index'
27
27
  import HtBaseData from './HtBaseData/index'
28
- import HtTwee from "./HtTwee/index"
28
+
29
29
 
30
30
 
31
31
 
32
32
  // 存储组件列表
33
- const components = [HtTwee, HtBaseData, HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown, HtUploadFiles, HtSelectBaseData, HtSelectOrg, HtSelectUser, HtShowBaseData, HtOrgInfo]
33
+ const components = [HtBaseData, HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown, HtUploadFiles, HtSelectBaseData, HtSelectOrg, HtSelectUser, HtShowBaseData, HtOrgInfo]
34
34
  // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
35
35
  const install = function (Vue: any) {
36
36
  // 判断是否安装
@@ -47,6 +47,6 @@ export default {
47
47
  install,
48
48
  // 以下是具体的组件列表
49
49
  HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown, HtUploadFiles,
50
- HtSelectBaseData, HtSelectOrg, HtSelectUser, HtShowBaseData, HtOrgInfo, HtBaseData, HtTwee
50
+ HtSelectBaseData, HtSelectOrg, HtSelectUser, HtShowBaseData, HtOrgInfo, HtBaseData
51
51
  }
52
52
 
@@ -0,0 +1,37 @@
1
+ /* eslint-disable @typescript-eslint/camelcase */
2
+ /*
3
+ * @Descripttion:
4
+ * @version:
5
+ * @Author: hutao
6
+ * @Date: 2022-05-06 17:56:08
7
+ * @LastEditors: hutao
8
+ * @LastEditTime: 2022-05-09 14:20:45
9
+ */
10
+ import Oidc from "oidc-client";
11
+ function getCurrentUrl() {
12
+ let href = window.location.pathname;
13
+ if (href.charAt(href.length - 1) === '/') {
14
+ href = href.substring(0, href.length - 1)
15
+ }
16
+ console.log('href', href, window.location);
17
+ console.log('window.location.host + href', window.location.origin + href);
18
+ return window.location.origin + href
19
+ }
20
+ export const mgr = new Oidc.UserManager({
21
+ // authority: "oauth2/api",//认证服务器
22
+ authority: "http://192.168.3.237:44318",//认证服务器
23
+ client_id: "AuthServer_App", //表示客户端的ID,必选项
24
+ //redirect_uri: "http://192.168.3.113:8082/product_architecture", //表示重定向URI,认证服务器回调的客户端页面。可选项
25
+ redirect_uri: getCurrentUrl(), //表示重定向URI,认证服务器回调的客户端页面。可选项
26
+ // redirect_uri: "http://192.168.3.252:4200", //表示重定向URI,认证服务器回调的客户端页面。可选项
27
+ response_type: "code", // response_type:表示授权类型,必选项
28
+ userStore: new Oidc.WebStorageStateStore({ store: window.localStorage }),
29
+ scope: "offline_access AuthServer", //scope:表示申请的权限范围,可选项
30
+ post_logout_redirect_uri: getCurrentUrl(),
31
+ automaticSilentRenew: false,
32
+
33
+ extraQueryParams: {
34
+ _tenant: 'default'
35
+ }
36
+
37
+ });
@@ -4,11 +4,11 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-11-15 14:41:40
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2022-04-29 17:03:44
7
+ * @LastEditTime: 2022-05-09 10:05:08
8
8
  -->
9
9
  <template>
10
10
  <div>
11
- <HtTwee></HtTwee>
11
+ ...................
12
12
  <HtSelectUser :value="['be12db32-1718-a43d-1cf8-39f97d1d872f','5f2d6558-4e98-9054-413f-39fc4c63ebac','959f6988-a74b-f6f7-0fb6-3a0314e0eaad']"
13
13
  :multiple="true"></HtSelectUser>
14
14
  <!-- <el-button type=""
@@ -1,22 +0,0 @@
1
- /*
2
- * @Descripttion:
3
- * @version:
4
- * @Author: hutao
5
- * @Date: 2022-04-29 16:30:37
6
- * @LastEditors: hutao
7
- * @LastEditTime: 2022-04-29 16:30:37
8
- */
9
- /*
10
- * @Descripttion:
11
- * @version:
12
- * @Author: hutao
13
- * @Date: 2021-11-15 15:00:57
14
- * @LastEditors: hutao
15
- * @LastEditTime: 2021-12-21 14:15:10
16
- */
17
- import HtTwee from "./index.vue";
18
- (HtTwee as any).install = function (Vue: any) {
19
-
20
- Vue.component("HtTwee", HtTwee);
21
- };
22
- export default HtTwee;
@@ -1,31 +0,0 @@
1
- <!--
2
- * @Descripttion:
3
- * @version:
4
- * @Author: hutao
5
- * @Date: 2022-04-29 16:30:40
6
- * @LastEditors: hutao
7
- * @LastEditTime: 2022-04-29 17:14:19
8
- -->
9
- <template>
10
-
11
- <canvas :ref="tweeRef||'ht-twee'"></canvas>
12
-
13
- </template>
14
- <script lang="ts">
15
- import { Vue, Component, Prop, Watch } from "vue-property-decorator";
16
- import { Httwee } from "@/plugins/HtTwee";
17
- require("@/plugins/EasePack.min.js");
18
- require("@/plugins/TweenLite.min.js");
19
- @Component
20
- export default class HtTwee extends Vue {
21
- @Prop() tweeRef!: string;
22
- @Prop() outerWidth!: number;
23
- @Prop() outerHeight!: number;
24
- created() {
25
- this.$nextTick(() => {
26
- Httwee(this.$refs["ht-twee"], this.outerWidth, this.outerHeight);
27
- });
28
- }
29
- }
30
- </script>
31
-
@@ -1,22 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-empty-function */
2
- /*
3
- * @Descripttion:
4
- * @version:
5
- * @Author: hutao
6
- * @Date: 2022-04-29 16:32:05
7
- * @LastEditors: hutao
8
- * @LastEditTime: 2022-04-29 16:57:19
9
- */
10
- /* eslint-disable no-var */
11
- /*!
12
- * VERSION: beta 1.9.4
13
- * DATE: 2014-07-17
14
- * UPDATES AND DOCS AT: http://www.greensock.com
15
- *
16
- * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
17
- * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
18
- * Club GreenSock members, the software agreement that was issued with your membership.
19
- *
20
- * @author: Jack Doyle, jack@greensock.com
21
- **/
22
- var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";_gsScope._gsDefine("easing.Back",["easing.Ease"],function(t){var e,i,s,r=_gsScope.GreenSockGlobals||_gsScope,n=r.com.greensock,a=2*Math.PI,o=Math.PI/2,h=n._class,l=function(e,i){var s=h("easing."+e,function(){},!0),r=s.prototype=new t;return r.constructor=s,r.getRatio=i,s},_=t.register||function(){},u=function(t,e,i,s){var r=h("easing."+t,{easeOut:new e,easeIn:new i,easeInOut:new s},!0);return _(r,t),r},c=function(t,e,i){this.t=t,this.v=e,i&&(this.next=i,i.prev=this,this.c=i.v-e,this.gap=i.t-t)},p=function(e,i){var s=h("easing."+e,function(t){this._p1=t||0===t?t:1.70158,this._p2=1.525*this._p1},!0),r=s.prototype=new t;return r.constructor=s,r.getRatio=i,r.config=function(t){return new s(t)},s},f=u("Back",p("BackOut",function(t){return(t-=1)*t*((this._p1+1)*t+this._p1)+1}),p("BackIn",function(t){return t*t*((this._p1+1)*t-this._p1)}),p("BackInOut",function(t){return 1>(t*=2)?.5*t*t*((this._p2+1)*t-this._p2):.5*((t-=2)*t*((this._p2+1)*t+this._p2)+2)})),m=h("easing.SlowMo",function(t,e,i){e=e||0===e?e:.7,null==t?t=.7:t>1&&(t=1),this._p=1!==t?e:0,this._p1=(1-t)/2,this._p2=t,this._p3=this._p1+this._p2,this._calcEnd=i===!0},!0),d=m.prototype=new t;return d.constructor=m,d.getRatio=function(t){var e=t+(.5-t)*this._p;return this._p1>t?this._calcEnd?1-(t=1-t/this._p1)*t:e-(t=1-t/this._p1)*t*t*t*e:t>this._p3?this._calcEnd?1-(t=(t-this._p3)/this._p1)*t:e+(t-e)*(t=(t-this._p3)/this._p1)*t*t*t:this._calcEnd?1:e},m.ease=new m(.7,.7),d.config=m.config=function(t,e,i){return new m(t,e,i)},e=h("easing.SteppedEase",function(t){t=t||1,this._p1=1/t,this._p2=t+1},!0),d=e.prototype=new t,d.constructor=e,d.getRatio=function(t){return 0>t?t=0:t>=1&&(t=.999999999),(this._p2*t>>0)*this._p1},d.config=e.config=function(t){return new e(t)},i=h("easing.RoughEase",function(e){e=e||{};for(var i,s,r,n,a,o,h=e.taper||"none",l=[],_=0,u=0|(e.points||20),p=u,f=e.randomize!==!1,m=e.clamp===!0,d=e.template instanceof t?e.template:null,g="number"==typeof e.strength?.4*e.strength:.4;--p>-1;)i=f?Math.random():1/u*p,s=d?d.getRatio(i):i,"none"===h?r=g:"out"===h?(n=1-i,r=n*n*g):"in"===h?r=i*i*g:.5>i?(n=2*i,r=.5*n*n*g):(n=2*(1-i),r=.5*n*n*g),f?s+=Math.random()*r-.5*r:p%2?s+=.5*r:s-=.5*r,m&&(s>1?s=1:0>s&&(s=0)),l[_++]={x:i,y:s};for(l.sort(function(t,e){return t.x-e.x}),o=new c(1,1,null),p=u;--p>-1;)a=l[p],o=new c(a.x,a.y,o);this._prev=new c(0,0,0!==o.t?o:o.next)},!0),d=i.prototype=new t,d.constructor=i,d.getRatio=function(t){var e=this._prev;if(t>e.t){for(;e.next&&t>=e.t;)e=e.next;e=e.prev}else for(;e.prev&&e.t>=t;)e=e.prev;return this._prev=e,e.v+(t-e.t)/e.gap*e.c},d.config=function(t){return new i(t)},i.ease=new i,u("Bounce",l("BounceOut",function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}),l("BounceIn",function(t){return 1/2.75>(t=1-t)?1-7.5625*t*t:2/2.75>t?1-(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}),l("BounceInOut",function(t){var e=.5>t;return t=e?1-2*t:2*t-1,t=1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5})),u("Circ",l("CircOut",function(t){return Math.sqrt(1-(t-=1)*t)}),l("CircIn",function(t){return-(Math.sqrt(1-t*t)-1)}),l("CircInOut",function(t){return 1>(t*=2)?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)})),s=function(e,i,s){var r=h("easing."+e,function(t,e){this._p1=t||1,this._p2=e||s,this._p3=this._p2/a*(Math.asin(1/this._p1)||0)},!0),n=r.prototype=new t;return n.constructor=r,n.getRatio=i,n.config=function(t,e){return new r(t,e)},r},u("Elastic",s("ElasticOut",function(t){return this._p1*Math.pow(2,-10*t)*Math.sin((t-this._p3)*a/this._p2)+1},.3),s("ElasticIn",function(t){return-(this._p1*Math.pow(2,10*(t-=1))*Math.sin((t-this._p3)*a/this._p2))},.3),s("ElasticInOut",function(t){return 1>(t*=2)?-.5*this._p1*Math.pow(2,10*(t-=1))*Math.sin((t-this._p3)*a/this._p2):.5*this._p1*Math.pow(2,-10*(t-=1))*Math.sin((t-this._p3)*a/this._p2)+1},.45)),u("Expo",l("ExpoOut",function(t){return 1-Math.pow(2,-10*t)}),l("ExpoIn",function(t){return Math.pow(2,10*(t-1))-.001}),l("ExpoInOut",function(t){return 1>(t*=2)?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))})),u("Sine",l("SineOut",function(t){return Math.sin(t*o)}),l("SineIn",function(t){return-Math.cos(t*o)+1}),l("SineInOut",function(t){return-.5*(Math.cos(Math.PI*t)-1)})),h("easing.EaseLookup",{find:function(e){return t.map[e]}},!0),_(r.SlowMo,"SlowMo","ease,"),_(i,"RoughEase","ease,"),_(e,"SteppedEase","ease,"),f},!0)}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()();
@@ -1,189 +0,0 @@
1
-
2
- let width, height, largeHeader, canvas, ctx, points, target, animateHeader = true;
3
- function getDistance(p1, p2) {
4
- return Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2);
5
- }
6
- function Circle(pos,rad,color) {
7
- // eslint-disable-next-line @typescript-eslint/no-this-alias
8
- const ttt = this;
9
-
10
- // constructor
11
- (function() {
12
- ttt.pos = pos || null;
13
- ttt.radius = rad || null;
14
- ttt.color = color || null;
15
- })();
16
-
17
- this.draw = function() {
18
- if(!ttt.active) return;
19
- ctx.beginPath();
20
- ctx.arc(ttt.pos.x, ttt.pos.y, ttt.radius, 0, 2 * Math.PI, false);
21
- ctx.fillStyle = 'rgba(156,217,249,'+ ttt.active+')';
22
- ctx.fill();
23
- };
24
- }
25
- function scrollCheck() {
26
- if(document.body.scrollTop > height) animateHeader = false;
27
- else animateHeader = true;
28
- }
29
-
30
- function shiftPoint(p) {
31
- TweenLite.to(p, 1+1*Math.random(), {x:p.originX-50+Math.random()*100,
32
- y: p.originY-50+Math.random()*100, ease:Circ.easeInOut,
33
- onComplete: function() {
34
- shiftPoint(p);
35
- }});
36
- }
37
-
38
- // Canvas manipulation
39
- function drawLines(p) {
40
- if(!p.active) return;
41
- for(const i in p.closest) {
42
- ctx.beginPath();
43
- ctx.moveTo(p.x, p.y);
44
- ctx.lineTo(p.closest[i].x, p.closest[i].y);
45
- ctx.strokeStyle = 'rgba(156,217,249,'+ p.active+')';
46
- ctx.stroke();
47
- }
48
- }
49
-
50
- function resize(outerWidth,outerHeight) {
51
- width =outerWidth|| window.innerWidth;
52
- height = outerHeight||window.innerHeight;
53
- // largeHeader.style.height = height+'px';
54
- canvas.width = width;
55
- canvas.height = height;
56
- }
57
- function mouseMove(e) {
58
- let posx = 0;let posy = 0;
59
- if (e.pageX || e.pageY) {
60
- posx = e.pageX;
61
- posy = e.pageY;
62
- }
63
- else if (e.clientX || e.clientY) {
64
- posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
65
- posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
66
- }
67
- target.x = posx;
68
- target.y = posy;
69
- }
70
- function initHeader(ref,outerWidth,outerHeight) {
71
- width = outerWidth||window.innerWidth;
72
- height =outerHeight|| window.innerHeight;
73
- target = {x: width/2, y: height/2};
74
-
75
- // largeHeader = document.getElementById('large-header');
76
- // largeHeader.style.height = height+'px';
77
-
78
- canvas = ref;
79
- canvas.width = width;
80
- canvas.height = height;
81
- ctx = canvas.getContext('2d');
82
-
83
- // create points
84
- points = [];
85
- for(let x = 0; x < width; x = x + width/20) {
86
- for(let y = 0; y < height; y = y + height/20) {
87
- const px = x + Math.random()*width/20;
88
- const py = y + Math.random()*height/20;
89
- const p = {x: px, originX: px, y: py, originY: py };
90
- points.push(p);
91
- }
92
- }
93
-
94
- // for each point find the 5 closest points
95
- for(let i = 0; i < points.length; i++) {
96
- const closest = [];
97
- const p1 = points[i];
98
- for(let j = 0; j < points.length; j++) {
99
- const p2 = points[j]
100
- if(!(p1 == p2)) {
101
- let placed = false;
102
- for(let k = 0; k < 5; k++) {
103
- if(!placed) {
104
- if(closest[k] == undefined) {
105
- closest[k] = p2;
106
- placed = true;
107
- }
108
- }
109
- }
110
-
111
- for(let k = 0; k < 5; k++) {
112
- if(!placed) {
113
- if(getDistance(p1, p2) < getDistance(p1, closest[k])) {
114
- closest[k] = p2;
115
- placed = true;
116
- }
117
- }
118
- }
119
- }
120
- }
121
- p1.closest = closest;
122
- }
123
-
124
- // assign a circle to each point
125
- for(const i in points) {
126
- const c = new Circle(points[i], 2+Math.random()*2, 'rgba(255,255,255,0.3)');
127
- points[i].circle = c;
128
- }
129
- }
130
-
131
- // Event handling
132
- function addListeners(width,height) {
133
- if(!('ontouchstart' in window)) {
134
- window.addEventListener('mousemove', mouseMove);
135
- }
136
- window.addEventListener('scroll', scrollCheck);
137
- window.addEventListener('resize', resize(width,height));
138
- }
139
-
140
-
141
-
142
-
143
-
144
-
145
- function animate() {
146
- if(animateHeader) {
147
- ctx.clearRect(0,0,width,height);
148
- for(const i in points) {
149
- // detect points in range
150
- if(Math.abs(getDistance(target, points[i])) < 4000) {
151
- points[i].active = 0.3;
152
- points[i].circle.active = 0.6;
153
- } else if(Math.abs(getDistance(target, points[i])) < 20000) {
154
- points[i].active = 0.1;
155
- points[i].circle.active = 0.3;
156
- } else if(Math.abs(getDistance(target, points[i])) < 40000) {
157
- points[i].active = 0.02;
158
- points[i].circle.active = 0.1;
159
- } else {
160
- points[i].active = 0;
161
- points[i].circle.active = 0;
162
- }
163
-
164
- drawLines(points[i]);
165
- points[i].circle.draw();
166
- }
167
- }
168
- requestAnimationFrame(animate);
169
- }
170
- // animation
171
- function initAnimation() {
172
- animate();
173
- for(const i in points) {
174
- shiftPoint(points[i]);
175
- }
176
- }
177
-
178
-
179
-
180
- // Util
181
-
182
- export function Httwee (ref,width,height) {
183
-
184
-
185
- // Main
186
- initHeader(ref,width,height);
187
- initAnimation();
188
- addListeners(width,height);
189
- };