ziko 0.65.0 → 0.67.0

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.
Files changed (113) hide show
  1. package/dist/ziko.cjs +61 -107
  2. package/dist/ziko.js +61 -107
  3. package/dist/ziko.min.js +2 -2
  4. package/dist/ziko.mjs +61 -107
  5. package/package.json +2 -2
  6. package/src/events/custom-events-registry/click-away.js +0 -1
  7. package/src/exp-events/controller/index.js +41 -0
  8. package/src/exp-events/custom-events-registry/click-away.js +39 -0
  9. package/src/exp-events/custom-events-registry/index.js +3 -0
  10. package/src/exp-events/custom-events-registry/swipe.js +76 -0
  11. package/src/exp-events/custom-events-registry/view.js +74 -0
  12. package/src/exp-events/details-setter/index.js +4 -0
  13. package/src/exp-events/details-setter/key.js +14 -0
  14. package/src/exp-events/details-setter/mouse.js +35 -0
  15. package/src/exp-events/details-setter/pointer.js +35 -0
  16. package/src/exp-events/details-setter/touch.js +37 -0
  17. package/src/exp-events/index.js +1 -0
  18. package/src/hooks/index.d.ts +11 -0
  19. package/src/hooks/use-derived.d.ts +14 -0
  20. package/src/hooks/use-event-emitter.d.ts +46 -0
  21. package/src/hooks/use-favicon.d.ts +41 -0
  22. package/src/hooks/use-ipc.d.ts +12 -0
  23. package/src/hooks/use-media-query.d.ts +24 -0
  24. package/src/hooks/use-reactive.d.ts +14 -0
  25. package/src/hooks/use-root.d.ts +15 -0
  26. package/src/hooks/use-state.d.ts +25 -0
  27. package/src/hooks/use-storage.d.ts +47 -0
  28. package/src/hooks/use-thread.d.ts +33 -0
  29. package/src/hooks/use-title.d.ts +37 -0
  30. package/src/index.d.ts +5 -0
  31. package/src/math/complex/index.d.ts +54 -0
  32. package/src/math/functions/index.d.ts +140 -0
  33. package/src/math/functions/logic/index.d.ts +11 -0
  34. package/src/math/functions/mapfun/index.d.ts +87 -0
  35. package/src/math/functions/utils/index.d.ts +1 -0
  36. package/src/math/functions/utils/mapfun.d.ts +43 -0
  37. package/src/math/index.d.ts +5 -0
  38. package/src/time/clocks/clock.d.ts +28 -0
  39. package/src/time/clocks/index.d.ts +3 -0
  40. package/src/time/clocks/scheduler.d.ts +42 -0
  41. package/src/time/clocks/tick.d.ts +26 -0
  42. package/src/time/decorators/index.d.ts +9 -0
  43. package/src/time/delay/index.d.ts +12 -0
  44. package/src/time/ease/index.d.ts +103 -0
  45. package/src/time/index.d.ts +4 -0
  46. package/src/time/loop/index.d.ts +50 -0
  47. package/src/ui/constructors/UIElement.js +19 -93
  48. package/src/ui/constructors/UIElementCore.d.ts +59 -0
  49. package/src/ui/constructors/UIElementCore.js +0 -9
  50. package/src/ui/constructors/UINode.d.ts +11 -0
  51. package/src/ui/constructors/UINode.js +1 -1
  52. package/src/ui/{__methods__ → constructors/mixins}/dom.js +1 -1
  53. package/src/ui/{__methods__ → constructors/mixins}/events.js +3 -3
  54. package/src/ui/{__methods__ → constructors/mixins}/style.js +1 -1
  55. package/src/ui/{__methods__ → constructors/mixins}/utils/index.js +4 -4
  56. package/src/ui/web-component/index.d.ts +14 -0
  57. package/src/ui/web-component/index.js +2 -2
  58. package/README.dep.md +0 -137
  59. package/src/--reactivity-deprecated/events/Input.js +0 -62
  60. package/src/--reactivity-deprecated/events/ZikoEvent.js +0 -92
  61. package/src/--reactivity-deprecated/events/__note__ +0 -1
  62. package/src/--reactivity-deprecated/events/custom-event.js +0 -57
  63. package/src/--reactivity-deprecated/events/hash.js +0 -47
  64. package/src/--reactivity-deprecated/events/index.js +0 -12
  65. package/src/--reactivity-deprecated/events/media.js +0 -1
  66. package/src/--reactivity-deprecated/events/mouse.js +0 -233
  67. package/src/--reactivity-deprecated/events/swipe.js +0 -149
  68. package/src/--reactivity-deprecated/events/touch.js +0 -0
  69. package/src/--reactivity-deprecated/hooks/Contexte/index.js +0 -1
  70. package/src/--reactivity-deprecated/hooks/Contexte/useSuccesifKeys.js +0 -14
  71. package/src/--reactivity-deprecated/hooks/UI/index.js +0 -6
  72. package/src/--reactivity-deprecated/hooks/UI/useCssLink.js +0 -0
  73. package/src/--reactivity-deprecated/hooks/UI/useLinearGradient.js +0 -0
  74. package/src/--reactivity-deprecated/hooks/UI/useMediaQuery.js +0 -43
  75. package/src/--reactivity-deprecated/hooks/UI/useRadialGradient.js +0 -0
  76. package/src/--reactivity-deprecated/hooks/UI/useRoot.js +0 -39
  77. package/src/--reactivity-deprecated/hooks/UI/useStyle.js +0 -79
  78. package/src/--reactivity-deprecated/hooks/UI/useTheme.js +0 -62
  79. package/src/--reactivity-deprecated/hooks/head/_useCssText.js +0 -21
  80. package/src/--reactivity-deprecated/hooks/head/index.js +0 -5
  81. package/src/--reactivity-deprecated/hooks/head/useFavIcon.js +0 -38
  82. package/src/--reactivity-deprecated/hooks/head/useHead.js +0 -28
  83. package/src/--reactivity-deprecated/hooks/head/useMeta.js +0 -52
  84. package/src/--reactivity-deprecated/hooks/head/useTitle.js +0 -30
  85. package/src/--reactivity-deprecated/hooks/index.js +0 -8
  86. package/src/--reactivity-deprecated/hooks/todo.md +0 -26
  87. package/src/--reactivity-deprecated/idea +0 -1
  88. package/src/--reactivity-deprecated/index.js +0 -3
  89. package/src/--reactivity-deprecated/observer/attributes.js +0 -28
  90. package/src/--reactivity-deprecated/observer/children.js +0 -37
  91. package/src/--reactivity-deprecated/observer/index.js +0 -6
  92. package/src/--reactivity-deprecated/observer/intersection.js +0 -44
  93. package/src/--reactivity-deprecated/observer/mutation.js +0 -113
  94. package/src/--reactivity-deprecated/observer/resize.js +0 -47
  95. package/src/--reactivity-deprecated/observer/screen.js +0 -45
  96. package/src/--reactivity-deprecated/observer/screen.js.txt +0 -84
  97. package/src/--reactivity-deprecated/observer/screen.txt +0 -13
  98. package/src/--use-deprecated/index.js +0 -11
  99. package/src/--use-deprecated/use-channel.js.txt +0 -61
  100. package/src/--use-deprecated/use-event-emmiter.js.txt +0 -64
  101. package/src/--use-deprecated/use-favicon.js +0 -0
  102. package/src/--use-deprecated/use-link.js +0 -0
  103. package/src/--use-deprecated/use-meta.js +0 -0
  104. package/src/--use-deprecated/use-root.js +0 -77
  105. package/src/--use-deprecated/use-storage.js.txt +0 -73
  106. package/src/--use-deprecated/use-thread.js +0 -44
  107. package/src/--use-deprecated/use-title.js +0 -0
  108. package/src/ui/constructors/_m.js.txt +0 -96
  109. package/src/ui/constructors/style/index.js +0 -506
  110. /package/src/ui/{__methods__ → constructors/mixins}/attrs.js +0 -0
  111. /package/src/ui/{__methods__ → constructors/mixins}/index.js +0 -0
  112. /package/src/ui/{__methods__ → constructors/mixins}/indexing.js +0 -0
  113. /package/src/ui/{__methods__ → constructors/mixins}/lifecycle.js +0 -0
package/README.dep.md DELETED
@@ -1,137 +0,0 @@
1
- <img src="docs/assets/logo-200.svg" width="100" align="right" alt="zikojs logo">
2
-
3
- *💡 **Zikojs** a versatile JavaScript library offering a rich set of UI components, advanced mathematical utilities, interactivity ,animations, client side routing and graphics capabilities*
4
-
5
- ## Install
6
- ```bash
7
- npm install ziko
8
- ```
9
- ## 🎬 Demos
10
- - ### [ Windows entanglement using zikojs and ziko-three ](https://www.linkedin.com/feed/update/urn:li:activity:7144023650394918913/)
11
-
12
- ## Features :
13
-
14
- ### 🔰 Seamlessly operates in both browser and Node.js environments
15
-
16
- ### 🔰 Mathematical Utilities & Tips
17
-
18
- - ***Flexible Math Functions*** :
19
-
20
- ZikoJS offers flexible math utilities, such as the `mapfun` function, which allows mapping standard mathematical operations to complex and nested data structures.
21
- For example, the `cos` function in ZikoJS is built on top of mapfun, enabling it to handle multiple arguments with diverse types (numbers, arrays, objects).
22
-
23
- ```js
24
- import { cos, PI } from "ziko";
25
- const result = cos(PI, PI / 2, PI / 4, [PI / 6, PI / 3], {
26
- x: PI / 2,
27
- y: PI / 4,
28
- z: [0, PI / 12],
29
- }
30
- );
31
- /*
32
- result =>
33
- [
34
- -1,
35
- 0,
36
- 0.707106781186548,
37
- [0.866025403784439, 0.5],
38
- {
39
- x: 0,
40
- y: 0.707106781186548,
41
- z: [1, 0.965925826289068],
42
- },
43
- ];
44
- */
45
- // console.log(result)
46
-
47
- ```
48
- You can also built your own flexible Math function using this mapfun util :
49
- ```js
50
- import { mapfun } from "ziko";
51
- const parabolic_func = (a, b, c, x) => a * x ** 2 + b * x + c;
52
- const map_parabolic_func =
53
- (a, b, c) =>
54
- (...X) =>
55
- mapfun((n) => parabolic_func(a, b, c, n), ...X);
56
- const a = -1.5,
57
- b = 2,
58
- c = 3;
59
- const X = [0, 1, 2, 3];
60
- console.log(parabolic_func(a, b, c)(X));
61
- // [3,3,1,3]
62
-
63
- ```
64
-
65
- - Built in Matrix, Complex, Random ... classes
66
-
67
- ### 🔰 No Template Engines :
68
- zikojs UI module adopts a distinctive approach to building and updating user interfaces. It doesn't rely on predefined markup templates. Instead, it leverages a hyperscript-like syntax to dynamically create and update user interfaces.
69
-
70
- ### 🔰 Built in File-Based Routing with Single Page Application
71
-
72
- ZikoJS provides an intuitive file-based routing mechanism that simplifies the development of single-page applications. By organizing your page components into a directory structure, you can automatically generate routes based on the file paths. This approach enhances the maintainability of your code by allowing you to easily manage and navigate between different views in your application.
73
-
74
- To implement file-based routing, simply use the following code:
75
-
76
- ```js
77
- import { FileBasedRouting } from "ziko";
78
- FileBasedRouting(import.meta.glob("./src/pages/**/*.js"))
79
- ```
80
- In this example, the import.meta.glob function dynamically imports all JavaScript files from the specified directory (./src/pages/**). Each file represents a separate route in your application, allowing you to create a clean and organized routing structure without the need for manual route configuration.
81
-
82
- ### 🔰 Flexible Integration with Popular Frameworks/Libraries
83
-
84
- **ZikoJS** is designed to seamlessly integrate into other frameworks and libraries. By installing the [ziko-wrapper](https://github.com/zakarialaoui10/ziko-wrapper) package, you can easily use ZikoJS within your favorite frontend ecosystems.
85
-
86
- Currently supported frameworks:
87
- - ***REACT***
88
- - ***Solid***
89
- - ***Preact***
90
- - ***Svelte***
91
- - ***Vue***
92
-
93
- ### 🔰 Custom Markdown Parser
94
-
95
- [Mdzjs](https://github.com/zakarialaoui10/mdzjs) allowing you to write markdown content alongside Zikojs Elements
96
-
97
- ```md
98
- ---
99
- title : Article 1
100
- ---
101
-
102
- import InteractiveBlock from "./InteractiveBlock";
103
-
104
- # Hello World this is markdown heading
105
-
106
- <InteractiveBlock data = "Hello" />
107
- ```
108
-
109
- ### 🔰 Growing Add-On Ecosystem
110
-
111
- |Addon|Purpose|Dependencies|Repository|
112
- |-|-|-|-|
113
- |ziko-gl||`threejs`|
114
- |ziko-code||`codeMirror`||
115
- |ziko-chart||`chartjs`||
116
- |ziko-pdf||`jsPdf.js`||
117
- |ziko-xls||`xls.js`||
118
- |ziko-lottie||`Lottie-web`|
119
- |ziko-rough||`rough.js`|
120
- |ziko-icons||`fontawesome`|
121
- |ziko-tippy||`tippy.js`|
122
-
123
-
124
- ### 🔰 Rich UI elements
125
-
126
- ### 🔰 Reactivity
127
-
128
- ### 🔰 Time loop and animations support
129
-
130
- ## ⭐️ Show your support <a name="support"></a>
131
-
132
- If you appreciate the library, kindly demonstrate your support by giving it a star!<br>
133
- [![Star](https://img.shields.io/github/stars/zakarialaoui10/ziko.js?style=social)](https://github.com/zakarialaoui10/ziko.js)
134
- <!--## Financial support-->
135
- # License
136
- This projet is licensed under the terms of MIT License
137
- <img src="https://img.shields.io/github/license/zakarialaoui10/zikojs?color=rgb%2820%2C21%2C169%29" width="100" align="right">
@@ -1,62 +0,0 @@
1
- import { ZikoEvent , EVENT_CONTROLLER } from "./ZikoEvent.js";
2
- function input_controller(e){
3
- EVENT_CONTROLLER.call(this,e,"input",null,null)
4
- }
5
- function change_controller(e){
6
- EVENT_CONTROLLER.call(this,e,"change",null,null)
7
- }
8
- class ZikoEventInput extends ZikoEvent{
9
- constructor(target){
10
- super(target);
11
- this.event=null;
12
- this.cache={
13
- prefixe:"",
14
- preventDefault:{
15
- input:false,
16
- change:false,
17
- },
18
- paused:{
19
- input:false,
20
- change:false,
21
- },
22
- stream:{
23
- enabled:{
24
- input:false,
25
- change:false,
26
- },
27
- clear:{
28
- input:false,
29
- change:false,
30
- },
31
- history:{
32
- input:[],
33
- change:[],
34
- }
35
- },
36
- callbacks:{
37
- input:[],
38
- change:[],
39
- }
40
- }
41
- this.__controller={
42
- input:input_controller.bind(this),
43
- change:change_controller.bind(this),
44
- }
45
- }
46
- get value(){
47
- return this.target.value;
48
- }
49
- onInput(...callbacks){
50
- this.__onEvent("input",{},...callbacks)
51
- return this;
52
- }
53
- onChange(...callbacks){
54
- this.__onEvent("change",{},...callbacks)
55
- return this;
56
- }
57
- }
58
- const useInputEvent=target=>new ZikoEventInput(target);
59
- export{
60
- useInputEvent,
61
- ZikoEventInput
62
- }
@@ -1,92 +0,0 @@
1
- function EVENT_CONTROLLER(e,EVENT,setter,push_object){
2
- this.event=e
3
- if(this.cache.preventDefault[EVENT])e.preventDefault();
4
- console.log({setter})
5
- if(setter)setter();
6
- if(this.cache.stream.enabled[EVENT]&&push_object)this.cache.stream.history[EVENT].push(push_object);
7
- this.cache.callbacks[EVENT].map(n=>n(this));
8
- return this;
9
- }
10
- class ZikoEvent{
11
- constructor(target){
12
- this.target=null;
13
- this.setTarget(target);
14
- this.__dispose=this.dispose.bind(this);
15
- // this.EventIndex=Garbage.Pointer.data.length;
16
- // Garbage.Pointer.data.push({event:this,index:this.EventIndex});
17
- }
18
- get targetElement(){
19
- return this.target.element
20
- }
21
- setTarget(UI){
22
- this.target=UI;
23
- return this;
24
- }
25
- __handle(event,handler,dispose){
26
- const EVENT=(event==="drag")?event:`${this.cache.prefixe}${event}`
27
- this.dispose(dispose);
28
- this.targetElement?.addEventListener(EVENT,handler);
29
- return this;
30
- }
31
- __onEvent(event,dispose,...callbacks){
32
- if(callbacks.length===0){
33
- if(this.cache.callbacks.length>1){
34
- this.cache.callbacks.map(n=>e=>n.call(this,e));
35
- }
36
- else {
37
- return this;
38
- }
39
- }
40
- else this.cache.callbacks[event]=callbacks.map(n=>e=>n.call(this,e));
41
- this.__handle(event,this.__controller[event],dispose)
42
- return this;
43
- }
44
- preventDefault(config={}){
45
- Object.assign(this.cache.preventDefault,config);
46
- return this;
47
- }
48
- pause(config={}){
49
- const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,true]))
50
- config={...all,...config}
51
- for(let key in config){
52
- if(config[key]){
53
- this.targetElement?.removeEventListener(`${this.cache.prefixe}${key}`,this.__controller[`${this.cache.prefixe}${key}`]);
54
- this.cache.paused[`${this.cache.prefixe}${key}`]=true;
55
- }
56
- }
57
- return this;
58
- }
59
- resume(config={}){
60
- const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,true]))
61
- config={...all,...config}
62
- for(let key in config){
63
- if(config[key]){
64
- this.targetElement?.addEventListener(`${this.cache.prefixe}${key}`,this.__controller[`${this.cache.prefixe}${key}`]);
65
- this.cache.paused[`${this.cache.prefixe}${key}`]=false;
66
- }
67
- }
68
- return this;
69
- }
70
- dispose(config={}){
71
- this.pause(config);
72
- return this;
73
- }
74
- stream(config={}){
75
- this.cache.stream.t0=Date.now();
76
- const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,true]))
77
- config={...all,...config}
78
- Object.assign(this.cache.stream.enabled,config);
79
- return this;
80
- }
81
- clear(config={}){
82
- const all=Object.fromEntries(Object.keys(this.cache.stream.clear).map(n=>[n,true]))
83
- config={...all,...config}
84
- for(let key in config){
85
- if(config[key]){
86
- this.cache.stream.history[key]=[]
87
- }
88
- }
89
- return this;
90
- }
91
- }
92
- export {ZikoEvent,EVENT_CONTROLLER}
@@ -1 +0,0 @@
1
- Should removed
@@ -1,57 +0,0 @@
1
- import { ZikoEvent , EVENT_CONTROLLER } from "./ZikoEvent.js";
2
- const custom_event_controller=event_name=>function(e){
3
- EVENT_CONTROLLER.call(this,e,event_name,null,null)
4
- }
5
- class ZikoCustomEvent extends ZikoEvent{
6
- constructor(target){
7
- super(target);
8
- this.event=null;
9
- this.cache={
10
- prefixe:"",
11
- preventDefault:{
12
- },
13
- paused:{
14
- },
15
- stream:{
16
- enabled:{
17
- },
18
- clear:{
19
- },
20
- history:{
21
- }
22
- },
23
- callbacks:{
24
- }
25
- }
26
- this.__controller={
27
- }
28
- }
29
- #init(event_name){
30
- this.cache.preventDefault[event_name]=false;
31
- this.cache.paused[event_name]=false;
32
- this.cache.stream.enabled=false;
33
- this.cache.stream.clear=false;
34
- this.cache.stream.history=[];
35
- this.cache.callbacks[event_name]=[]
36
- this.__controller[event_name]=custom_event_controller(event_name).bind(this);
37
- return this;
38
- }
39
- on(event_name,...callbacks){
40
- if(!(this.__controller[event_name]))this.#init(event_name);
41
- this.__onEvent(event_name,{},...callbacks)
42
- return this;
43
- }
44
- emit(event_name,detail={}){
45
- if(!(this.__controller[event_name]))this.#init(event_name);
46
- this.detail=detail;
47
- const event=new Event(event_name);
48
- this.targetElement.dispatchEvent(event);
49
- return this;
50
- }
51
- }
52
- const useCustomEvent=target=>new ZikoCustomEvent(target);
53
-
54
- export{
55
- useCustomEvent,
56
- ZikoCustomEvent
57
- }
@@ -1,47 +0,0 @@
1
- import { ZikoEvent , EVENT_CONTROLLER } from "./ZikoEvent.js";
2
- function hashchange_controller(e){
3
- EVENT_CONTROLLER.call(this,e,"hashchange",null,null)
4
- }
5
- class ZikoEventHash extends ZikoEvent{
6
- constructor(target){
7
- super(target);
8
- this.event=null;
9
- this.cache={
10
- prefixe:"",
11
- preventDefault:{
12
- hashchange:false,
13
- },
14
- paused:{
15
- hashchange:false,
16
- },
17
- stream:{
18
- enabled:{
19
- hashchange:false,
20
-
21
- },
22
- clear:{
23
- hashchange:false,
24
-
25
- },
26
- history:{
27
- hashchange:[],
28
- }
29
- },
30
- callbacks:{
31
- hashchange:[],
32
- }
33
- }
34
- this.__controller={
35
- hashchange:hashchange_controller.bind(this),
36
- }
37
- }
38
- onChange(...callbacks){
39
- this.__onEvent("hashchange",{},...callbacks)
40
- return this;
41
- }
42
- }
43
- const useHashEvent=target=>new ZikoEventHash(target);
44
- export{
45
- useHashEvent,
46
- ZikoEventHash
47
- }
@@ -1,12 +0,0 @@
1
- // export * from "./click.js";
2
- // export * from "./pointer.js";
3
- // export * from "./mouse.js";
4
- // export * from "./wheel.js";
5
- // export * from "./key.js";
6
- // export * from "./drag.js";
7
- // export * from "./clipboard.js";
8
- // export * from "./focus.js";
9
- export * from "./Input.js";
10
- export * from "./hash.js";
11
- export * from "./custom-event.js";
12
- export * from "./swipe.js"
@@ -1 +0,0 @@
1
- // Timeupdate
@@ -1,233 +0,0 @@
1
- import {ZikoEvent,EVENT_CONTROLLER} from "./ZikoEvent.js";
2
- class ZikoEventMouse extends ZikoEvent{
3
- constructor(target){
4
- super(target);
5
- this.event=null;
6
- this.dx=0;
7
- this.dy=0;
8
- this.dt=0;
9
- this.mx=0;
10
- this.my=0;
11
- this.mt=0;
12
- this.ux=0;
13
- this.uy=0;
14
- this.ut=0;
15
- this.swippe={
16
- h:null,
17
- v:null,
18
- delta_x:0,
19
- delta_y:0
20
- }
21
- this.isMoving=false;
22
- this.isDown=false;
23
- this.cache={
24
- prefixe:"mouse",
25
- preventDefault:{
26
- down:false,
27
- move:false,
28
- up:false,
29
- enter:false,
30
- out:false,
31
- leave:false,
32
- over:false,
33
- },
34
- paused:{
35
- down:false,
36
- move:false,
37
- up:false,
38
- enter:false,
39
- out:false,
40
- leave:false,
41
- over:false,
42
- },
43
- stream:{
44
- enabled:{
45
- down:false,
46
- move:false,
47
- up:false,
48
- enter:false,
49
- out:false,
50
- leave:false,
51
- over:false,
52
- },
53
- clear:{
54
- down:false,
55
- move:false,
56
- up:false,
57
- enter:false,
58
- out:false,
59
- leave:false,
60
- over:false,
61
- },
62
- history:{
63
- down:[],
64
- move:[],
65
- up:[],
66
- enter:[],
67
- out:[],
68
- leave:[],
69
- over:[]
70
- }
71
- },
72
- callbacks:{
73
- down:[(self)=>console.log({dx:self.dx,dy:self.dy,down:self.down,move:self.move,t:self.dt})],
74
- move:[(self)=>console.log({mx:self.mx,my:self.my,down:self.down,move:self.move,t:self.dt})],
75
- up:[(self)=>console.log({ux:self.ux,uy:self.uy,down:self.down,move:self.move,t:self.dt})],
76
- enter:[(self)=>console.log({dx:self.dx,dy:self.dy,down:self.down,move:self.move,t:self.dt})],
77
- out:[(self)=>console.log({mx:self.mx,my:self.my,down:self.down,move:self.move,t:self.dt})],
78
- leave:[(self)=>console.log({ux:self.ux,uy:self.uy,down:self.down,move:self.move,t:self.dt})],
79
- over:[(self)=>console.log({ux:self.ux,uy:self.uy,down:self.down,move:self.move,t:self.dt})]
80
- }
81
- }
82
- this.__controller={
83
- down:mousedown_controller.bind(this),
84
- move:mousemove_controller.bind(this),
85
- up:mouseup_controller.bind(this),
86
- enter:mouseenter_controller.bind(this),
87
- out:mouseout_controller.bind(this),
88
- leave:mouseleave_controller.bind(this),
89
- over:mouseover_controller.bind(this),
90
- }
91
- }
92
- onDown(...callbacks){
93
- if(callbacks.length===0)callbacks=[()=>{}];
94
- this.__onEvent("down",{down:true,move:false,up:false,enter:false,out:false,leave:false,over:false},...callbacks)
95
- return this;
96
- }
97
- onMove(...callbacks){
98
- if(callbacks.length===0)callbacks=[()=>{}];
99
- this.__onEvent("move",{down:false,move:true,up:false,enter:false,out:false,leave:false,over:false},...callbacks)
100
- return this;
101
- }
102
- onUp(...callbacks){
103
- if(callbacks.length===0)callbacks=[()=>{}];
104
- this.__onEvent("up",{down:false,move:false,up:true,enter:false,out:false,leave:false,over:false},...callbacks)
105
- return this;
106
- }
107
- onEnter(...callbacks){
108
- if(callbacks.length===0)callbacks=[()=>{}];
109
- this.__onEvent("enter",{down:false,move:false,up:false,enter:true,out:false,leave:false,over:false},...callbacks)
110
- return this;
111
- }
112
- onOut(...callbacks){
113
- if(callbacks.length===0)callbacks=[()=>{}];
114
- this.__onEvent("out",{down:false,move:false,up:false,enter:false,out:true,leave:false,over:false},...callbacks)
115
- return this;
116
- }
117
- onLeave(...callbacks){
118
- if(callbacks.length===0)callbacks=[()=>{}];
119
- this.__onEvent("leave",{down:false,move:false,up:false,enter:false,out:false,leave:true,over:false},...callbacks)
120
- return this;
121
- }
122
- onOver(...callbacks){
123
- if(callbacks.length===0)callbacks=[()=>{}];
124
- this.__onEvent("over",{down:false,move:false,up:false,enter:false,out:false,leave:false,over:true},...callbacks)
125
- return this;
126
- }
127
- }
128
- function mousedown_controller(e){
129
- EVENT_CONTROLLER.call(
130
- this,
131
- e,
132
- "down",
133
- ()=>{
134
- this.dx=parseInt(e.offsetX);
135
- this.dy=parseInt(e.offsetY);
136
- this.isDown=true;
137
- },
138
- {
139
- x:this.dx,
140
- y:this.dy,
141
- t:Date.now()-this.cache.stream.t0
142
- }
143
- )
144
- }
145
- function mousemove_controller(e){
146
- EVENT_CONTROLLER.call(
147
- this,
148
- e,
149
- "move",
150
- ()=>{
151
- this.mx=parseInt(e.offsetX);
152
- this.my=parseInt(e.offsetY);
153
- this.isMoving=true;
154
- },
155
- {
156
- x:this.mx,
157
- y:this.my,
158
- t:Date.now()-this.cache.stream.t0
159
- }
160
- )
161
- }
162
- function mouseup_controller(e){
163
- EVENT_CONTROLLER.call(
164
- this,
165
- e,
166
- "up",
167
- ()=>{
168
- this.ux=parseInt(e.offsetX);
169
- this.uy=parseInt(e.offsetY);
170
- this.isDown=false;
171
- const dx=this.dx;
172
- const dy=this.dy;
173
- const ux=this.ux;
174
- const uy=this.uy;
175
- const delta_x=(ux-dx)/this.target.Width;
176
- const delta_y=(dy-uy)/this.target.Height;
177
- const HORIZONTAL_SWIPPE=(delta_x<0)?"left":(delta_x>0)?"right":"none";
178
- const VERTICAL_SWIPPE=(delta_y<0)?"bottom":(delta_y>0)?"top":"none";
179
- this.swippe={
180
- h:HORIZONTAL_SWIPPE,
181
- v:VERTICAL_SWIPPE,
182
- delta_x,
183
- delta_y
184
- }
185
- },
186
- {
187
- x:this.ux,
188
- y:this.uy,
189
- t:Date.now()-this.cache.stream.t0
190
- }
191
- )
192
- }
193
- function mouseenter_controller(e){
194
- EVENT_CONTROLLER.call(
195
- this,
196
- e,
197
- "enter",
198
- null,
199
- null
200
- )
201
- }
202
- function mouseleave_controller(e){
203
- EVENT_CONTROLLER.call(
204
- this,
205
- e,
206
- "leave",
207
- null,
208
- null
209
- )
210
- }
211
- function mouseout_controller(e){
212
- EVENT_CONTROLLER.call(
213
- this,
214
- e,
215
- "out",
216
- null,
217
- null
218
- )
219
- }
220
- function mouseover_controller(e){
221
- EVENT_CONTROLLER.call(
222
- this,
223
- e,
224
- "out",
225
- null,
226
- null
227
- )
228
- }
229
- const useMouseEvent=target=>new ZikoEventMouse(target);
230
- export{
231
- useMouseEvent,
232
- ZikoEventMouse
233
- }