ziko 0.0.1
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.
- package/LICENSE +21 -0
- package/README.md +316 -0
- package/dist/ziko.cjs +9786 -0
- package/dist/ziko.js +9792 -0
- package/dist/ziko.min.js +9 -0
- package/dist/ziko.mjs +9567 -0
- package/package.json +55 -0
- package/src/App/Accessibility/index.js +0 -0
- package/src/App/Globals/__Target__.js +3 -0
- package/src/App/Globals/__UI__.js +38 -0
- package/src/App/Globals/__init__.js +8 -0
- package/src/App/Globals/index.js +3 -0
- package/src/App/Router/index.js +40 -0
- package/src/App/Seo/index.js +43 -0
- package/src/App/Themes/dark.js +885 -0
- package/src/App/Themes/index.js +11 -0
- package/src/App/Themes/light.js +255 -0
- package/src/App/app.js +37 -0
- package/src/App/index.js +11 -0
- package/src/Data/Api/fetchdom.js +14 -0
- package/src/Data/Api/index.js +4 -0
- package/src/Data/Api/preload.js +11 -0
- package/src/Data/Converter/canvas.js +25 -0
- package/src/Data/Converter/csv.js +33 -0
- package/src/Data/Converter/index.js +25 -0
- package/src/Data/Converter/json.js +80 -0
- package/src/Data/Converter/markdown.js +83 -0
- package/src/Data/Converter/svg.js +11 -0
- package/src/Data/Parser/markdown.js +0 -0
- package/src/Data/Parser/xml.js +47 -0
- package/src/Data/Strings/index.js +26 -0
- package/src/Data/decorators.js +0 -0
- package/src/Data/index.js +64 -0
- package/src/Graphics/Canvas/Elements/Basic/arc.js +43 -0
- package/src/Graphics/Canvas/Elements/Basic/image.js +0 -0
- package/src/Graphics/Canvas/Elements/Basic/line.js +26 -0
- package/src/Graphics/Canvas/Elements/Basic/path.js +0 -0
- package/src/Graphics/Canvas/Elements/Basic/points.js +48 -0
- package/src/Graphics/Canvas/Elements/Basic/polygon.js +7 -0
- package/src/Graphics/Canvas/Elements/Basic/polyline.js +0 -0
- package/src/Graphics/Canvas/Elements/Basic/rect.js +46 -0
- package/src/Graphics/Canvas/Elements/Basic/text.js +0 -0
- package/src/Graphics/Canvas/Elements/Chart/histogram.js +0 -0
- package/src/Graphics/Canvas/Elements/Chart/plot.js +0 -0
- package/src/Graphics/Canvas/Elements/Chart/scatter.js +2 -0
- package/src/Graphics/Canvas/Elements/Chart/stem.js +0 -0
- package/src/Graphics/Canvas/Elements/Element.js +115 -0
- package/src/Graphics/Canvas/Elements/Groupe.js +0 -0
- package/src/Graphics/Canvas/Elements/grid.js +0 -0
- package/src/Graphics/Canvas/Elements/index.js +13 -0
- package/src/Graphics/Canvas/Filter/index.js +0 -0
- package/src/Graphics/Canvas/Paint/index.js +0 -0
- package/src/Graphics/Canvas/Utils/color.js +8 -0
- package/src/Graphics/Canvas/Utils/floodFill.js +58 -0
- package/src/Graphics/Canvas/_canvas_offscreen +0 -0
- package/src/Graphics/Canvas/canvas.js +189 -0
- package/src/Graphics/Canvas/index.js +15 -0
- package/src/Graphics/Svg/Elements/ZikoSvgElement.js +28 -0
- package/src/Graphics/Svg/Elements/circle.js +34 -0
- package/src/Graphics/Svg/Elements/ellipse.js +29 -0
- package/src/Graphics/Svg/Elements/foreignObject.js +46 -0
- package/src/Graphics/Svg/Elements/grid.js +9 -0
- package/src/Graphics/Svg/Elements/groupe.js +29 -0
- package/src/Graphics/Svg/Elements/image.js +33 -0
- package/src/Graphics/Svg/Elements/line.js +29 -0
- package/src/Graphics/Svg/Elements/path.js +59 -0
- package/src/Graphics/Svg/Elements/polygon.js +31 -0
- package/src/Graphics/Svg/Elements/polyline.js +4 -0
- package/src/Graphics/Svg/Elements/rect.js +43 -0
- package/src/Graphics/Svg/Elements/text.js +26 -0
- package/src/Graphics/Svg/index.js +1 -0
- package/src/Graphics/Svg/svg.js +117 -0
- package/src/Graphics/index.js +61 -0
- package/src/Math/Calculus/Special Functions/bessel.js +31 -0
- package/src/Math/Calculus/Special Functions/beta.js +38 -0
- package/src/Math/Calculus/Special Functions/gamma.js +30 -0
- package/src/Math/Calculus/Special Functions/index.js +4 -0
- package/src/Math/Calculus/index.js +1 -0
- package/src/Math/Complex/Fractals/julia.js +0 -0
- package/src/Math/Complex/index.js +191 -0
- package/src/Math/Discret/Combinaison/index.js +34 -0
- package/src/Math/Discret/Conversion/index.js +86 -0
- package/src/Math/Discret/Logic/index.js +46 -0
- package/src/Math/Discret/Permutation/index.js +31 -0
- package/src/Math/Discret/Set/index.js +2 -0
- package/src/Math/Discret/Set/powerSet.js +15 -0
- package/src/Math/Discret/Set/subSet.js +10 -0
- package/src/Math/Discret/index.js +23 -0
- package/src/Math/Functions/index.js +182 -0
- package/src/Math/Matrix/Decomposition.js +90 -0
- package/src/Math/Matrix/LinearSystem.js +10 -0
- package/src/Math/Matrix/Matrix.js +712 -0
- package/src/Math/Matrix/index.js +3 -0
- package/src/Math/Numeric/index.js +0 -0
- package/src/Math/Random/index.js +173 -0
- package/src/Math/Signal/__np.py.txt +40 -0
- package/src/Math/Signal/conv.js +175 -0
- package/src/Math/Signal/fft.js +55 -0
- package/src/Math/Signal/filter.js +39 -0
- package/src/Math/Signal/functions.js +146 -0
- package/src/Math/Signal/index.js +110 -0
- package/src/Math/Statistics/Functions/index.js +100 -0
- package/src/Math/Statistics/index.js +16 -0
- package/src/Math/Utils/arithmetic.js +139 -0
- package/src/Math/Utils/checkers.js +11 -0
- package/src/Math/Utils/comparaison.js +1 -0
- package/src/Math/Utils/conversions.js +7 -0
- package/src/Math/Utils/discret.js +28 -0
- package/src/Math/Utils/index.js +102 -0
- package/src/Math/Utils/mapfun.js +43 -0
- package/src/Math/absract.js +1 -0
- package/src/Math/const.js +3 -0
- package/src/Math/index.js +193 -0
- package/src/Reactivity/Events/Global/Click.js +56 -0
- package/src/Reactivity/Events/Global/Clipboard.js +84 -0
- package/src/Reactivity/Events/Global/CustomEvent.js +53 -0
- package/src/Reactivity/Events/Global/Drag.js +137 -0
- package/src/Reactivity/Events/Global/Focus.js +56 -0
- package/src/Reactivity/Events/Global/Key.js +104 -0
- package/src/Reactivity/Events/Global/Pointer.js +214 -0
- package/src/Reactivity/Events/Partiel/Input.js +59 -0
- package/src/Reactivity/Events/ZikoEvent.js +91 -0
- package/src/Reactivity/Events/index.js +51 -0
- package/src/Reactivity/Observer/index.js +3 -0
- package/src/Reactivity/Observer/intersection.js +40 -0
- package/src/Reactivity/Observer/mutation.js +90 -0
- package/src/Reactivity/Observer/resize.js +47 -0
- package/src/Reactivity/Use/Contexte/index.js +1 -0
- package/src/Reactivity/Use/Contexte/useSuccesifKeys.js +14 -0
- package/src/Reactivity/Use/Decorators/index.js +4 -0
- package/src/Reactivity/Use/Interactions/index.js +4 -0
- package/src/Reactivity/Use/Interactions/useBluetooth.js +48 -0
- package/src/Reactivity/Use/Interactions/useChannel.js +50 -0
- package/src/Reactivity/Use/Interactions/useEventEmmiter.js +64 -0
- package/src/Reactivity/Use/Interactions/useSerial.js +0 -0
- package/src/Reactivity/Use/Interactions/useThread.js +44 -0
- package/src/Reactivity/Use/Interactions/useUsb.js +0 -0
- package/src/Reactivity/Use/Sensors/index.js +2 -0
- package/src/Reactivity/Use/Sensors/useBattery.js +36 -0
- package/src/Reactivity/Use/Sensors/useCamera.js +0 -0
- package/src/Reactivity/Use/Sensors/useGeolocation.js +17 -0
- package/src/Reactivity/Use/Sensors/useMicro.js +0 -0
- package/src/Reactivity/Use/Sensors/useOrientation.js +0 -0
- package/src/Reactivity/Use/Storage/index.js +1 -0
- package/src/Reactivity/Use/Storage/useCookie.js +0 -0
- package/src/Reactivity/Use/Storage/useIndexedDb.js +0 -0
- package/src/Reactivity/Use/Storage/useStorage.js +74 -0
- package/src/Reactivity/Use/UI/index.js +4 -0
- package/src/Reactivity/Use/UI/useCssLink.js +0 -0
- package/src/Reactivity/Use/UI/useCssText.js +21 -0
- package/src/Reactivity/Use/UI/useFavIcon.js +38 -0
- package/src/Reactivity/Use/UI/useLinearGradient.js +0 -0
- package/src/Reactivity/Use/UI/useMediaQuery.js +1 -0
- package/src/Reactivity/Use/UI/useRadialGradient.js +0 -0
- package/src/Reactivity/Use/UI/useStyle.js +54 -0
- package/src/Reactivity/Use/UI/useTheme.js +62 -0
- package/src/Reactivity/Use/UI/useTitle.js +30 -0
- package/src/Reactivity/Use/index.js +82 -0
- package/src/Reactivity/Use/todo.md +26 -0
- package/src/Reactivity/index.js +3 -0
- package/src/Time/animation.js +76 -0
- package/src/Time/index.js +54 -0
- package/src/Time/loop.js +83 -0
- package/src/Time/utils/decorators.js +17 -0
- package/src/Time/utils/ease.js +144 -0
- package/src/Time/utils/index.js +18 -0
- package/src/Time/utils/performance.js +16 -0
- package/src/Time/utils/ui.js +26 -0
- package/src/UI/CustomElement/Elements/Accordion/index.js +62 -0
- package/src/UI/CustomElement/Elements/Carousel/index.js +47 -0
- package/src/UI/CustomElement/Elements/CodeNote/CodeCell.js +176 -0
- package/src/UI/CustomElement/Elements/CodeNote/CodeNote.js +69 -0
- package/src/UI/CustomElement/Elements/CodeNote/SubElements.js +64 -0
- package/src/UI/CustomElement/Elements/CodeNote/index.js +2 -0
- package/src/UI/CustomElement/Elements/Columns.js +1 -0
- package/src/UI/CustomElement/Elements/FAB.js +0 -0
- package/src/UI/CustomElement/Elements/Menu.js +0 -0
- package/src/UI/CustomElement/Elements/Notification.js +0 -0
- package/src/UI/CustomElement/Elements/Popover.js +0 -0
- package/src/UI/CustomElement/Elements/Popup.js +0 -0
- package/src/UI/CustomElement/Elements/Swipper.js +4 -0
- package/src/UI/CustomElement/Elements/Tabs/index.js +111 -0
- package/src/UI/CustomElement/Elements/Timeline.js +0 -0
- package/src/UI/CustomElement/Elements/Toast.js +0 -0
- package/src/UI/CustomElement/Elements/Treeview.js +0 -0
- package/src/UI/CustomElement/Elements/index.js +4 -0
- package/src/UI/CustomElement/Flex.js +97 -0
- package/src/UI/CustomElement/Grid.js +30 -0
- package/src/UI/CustomElement/index.js +3 -0
- package/src/UI/Embaded/index.js +1 -0
- package/src/UI/Inputs/Primitives/btn.js +31 -0
- package/src/UI/Inputs/Primitives/elements.js +28 -0
- package/src/UI/Inputs/Primitives/inputs.js +334 -0
- package/src/UI/Inputs/Primitives/select.js +15 -0
- package/src/UI/Inputs/Primitives/textarea.js +16 -0
- package/src/UI/Inputs/camera.js +23 -0
- package/src/UI/Inputs/index.js +20 -0
- package/src/UI/List/elements.js +0 -0
- package/src/UI/List/index.js +130 -0
- package/src/UI/Media/Audio/index.js +26 -0
- package/src/UI/Media/Image/figure.js +17 -0
- package/src/UI/Media/Image/image.js +34 -0
- package/src/UI/Media/Image/index.js +2 -0
- package/src/UI/Media/Video/index.js +37 -0
- package/src/UI/Media/index.js +3 -0
- package/src/UI/Misc/index.js +49 -0
- package/src/UI/Semantic/index.js +68 -0
- package/src/UI/Style/index.js +499 -0
- package/src/UI/Table/elements.js +94 -0
- package/src/UI/Table/index.js +3 -0
- package/src/UI/Table/table.js +113 -0
- package/src/UI/Table/utils.js +12 -0
- package/src/UI/Text/heading.js +35 -0
- package/src/UI/Text/index.js +3 -0
- package/src/UI/Text/p.js +37 -0
- package/src/UI/Text/pre.js +0 -0
- package/src/UI/Text/text.js +66 -0
- package/src/UI/Utils/index.js +70 -0
- package/src/UI/ZikoUIElement.js +478 -0
- package/src/UI/index.js +154 -0
- package/src/__proto__/Array.js +74 -0
- package/src/__proto__/Function.js +0 -0
- package/src/__proto__/Number.js +76 -0
- package/src/__proto__/Object.js +0 -0
- package/src/__proto__/String.js +0 -0
- package/src/index.js +69 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Ease } from "./utils";
|
|
2
|
+
import { map } from "../Math/Utils"
|
|
3
|
+
class ZikoTimeAnimation{
|
|
4
|
+
constructor(callback,{ease=Ease.Linear,step=50,t=[0,null],start=true,duration=3000}={}){
|
|
5
|
+
this.cache={
|
|
6
|
+
isRunning:false,
|
|
7
|
+
AnimationId:null,
|
|
8
|
+
startTime:null,
|
|
9
|
+
ease,
|
|
10
|
+
step,
|
|
11
|
+
intervall:t,
|
|
12
|
+
started:start,
|
|
13
|
+
duration
|
|
14
|
+
}
|
|
15
|
+
this.t=0;
|
|
16
|
+
this.tx=0;
|
|
17
|
+
this.ty=0;
|
|
18
|
+
this.i=0;
|
|
19
|
+
this.callback=callback;
|
|
20
|
+
}
|
|
21
|
+
#animation_handler(){
|
|
22
|
+
this.t+=this.cache.step;
|
|
23
|
+
this.i++;
|
|
24
|
+
this.tx=map(this.t,0,this.cache.duration,0,1);
|
|
25
|
+
this.ty=this.cache.ease(this.tx);
|
|
26
|
+
this.callback(this)
|
|
27
|
+
if(this.t>=this.cache.duration){
|
|
28
|
+
clearInterval(this.cache.AnimationId);
|
|
29
|
+
this.cache.isRunning=false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
reset(restart=true){
|
|
33
|
+
this.t=0
|
|
34
|
+
this.tx=0;
|
|
35
|
+
this.ty=0;
|
|
36
|
+
this.i=0;
|
|
37
|
+
if(restart)this.start();
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
#animate(reset=true){
|
|
41
|
+
if(!this.cache.isRunning){
|
|
42
|
+
if(reset)this.reset(false);
|
|
43
|
+
this.cache.isRunning=true;
|
|
44
|
+
this.cache.startTime = Date.now();
|
|
45
|
+
this.cache.AnimationId=setInterval(this.#animation_handler.bind(this),this.cache.step);
|
|
46
|
+
}
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
start(){
|
|
50
|
+
this.#animate(true);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
pause(){
|
|
54
|
+
if (this.cache.isRunning) {
|
|
55
|
+
clearTimeout(this.cache.AnimationId);
|
|
56
|
+
this.cache.isRunning = false;
|
|
57
|
+
}
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
resume(){
|
|
61
|
+
this.#animate(false);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
stop(){
|
|
65
|
+
this.pause();
|
|
66
|
+
this.reset(false);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
// clear(){
|
|
70
|
+
// }
|
|
71
|
+
// stream(){
|
|
72
|
+
// }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const animation=(callback,config)=>new ZikoTimeAnimation(callback,config)
|
|
76
|
+
export{animation}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import{
|
|
2
|
+
loop
|
|
3
|
+
} from "./loop.js"
|
|
4
|
+
import{
|
|
5
|
+
animation
|
|
6
|
+
} from "./animation.js"
|
|
7
|
+
import {
|
|
8
|
+
wait,
|
|
9
|
+
timeTaken,
|
|
10
|
+
useThrottle,
|
|
11
|
+
useDebounce,
|
|
12
|
+
Ease,
|
|
13
|
+
time_memory_Taken,
|
|
14
|
+
waitForUIElm,
|
|
15
|
+
waitForUIElmSync
|
|
16
|
+
} from "./utils/index.js";
|
|
17
|
+
const Time={
|
|
18
|
+
wait,
|
|
19
|
+
timeTaken,
|
|
20
|
+
useThrottle,
|
|
21
|
+
useDebounce,
|
|
22
|
+
Ease,
|
|
23
|
+
time_memory_Taken,
|
|
24
|
+
loop,
|
|
25
|
+
animation,
|
|
26
|
+
waitForUIElm,
|
|
27
|
+
waitForUIElmSync,
|
|
28
|
+
ExtractAll: function () {
|
|
29
|
+
const keys = Object.keys(this);
|
|
30
|
+
for (let i = 0; i < keys.length; i++) {
|
|
31
|
+
const key = keys[i];
|
|
32
|
+
if (key !== 'ExtractAll' && key !== 'RemoveAll') {
|
|
33
|
+
globalThis[key] = this[key];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return this;
|
|
37
|
+
},
|
|
38
|
+
RemoveAll: function () {
|
|
39
|
+
const keys = Object.keys(this);
|
|
40
|
+
for (let i = 0; i < keys.length; i++) {
|
|
41
|
+
const key = keys[i];
|
|
42
|
+
if (key !== 'RemoveAll') {
|
|
43
|
+
delete globalThis[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export * from "./utils/index.js"
|
|
50
|
+
export {
|
|
51
|
+
loop,
|
|
52
|
+
animation
|
|
53
|
+
}
|
|
54
|
+
export default Time;
|
package/src/Time/loop.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
class ZikoTimeLoop {
|
|
2
|
+
constructor(callback, {fps,step,t=[0,null],start=true}={}) {
|
|
3
|
+
this.callback = callback;
|
|
4
|
+
this.cache = {
|
|
5
|
+
isRunning: false,
|
|
6
|
+
AnimationId : null,
|
|
7
|
+
startTime : null,
|
|
8
|
+
step,
|
|
9
|
+
fps,
|
|
10
|
+
t,
|
|
11
|
+
started:start
|
|
12
|
+
};
|
|
13
|
+
this.adjust();
|
|
14
|
+
this.i=0;
|
|
15
|
+
}
|
|
16
|
+
adjust(){
|
|
17
|
+
if(this.cache.step && this.cache.fps){
|
|
18
|
+
console.warn(`Fps will be adjusted from ${this.cache.fps} to ${1000/this.cache.step} to ensure a smoother animation`);
|
|
19
|
+
this.cache.fps=1000/this.cache.step;
|
|
20
|
+
}
|
|
21
|
+
if(this.cache.started){
|
|
22
|
+
const t=this.cache.t;
|
|
23
|
+
t[0]?this.startAfter(t[0]):this.start();
|
|
24
|
+
if(t[1])this.stopAfter(t[1]);
|
|
25
|
+
}
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
get TIME_STEP() {
|
|
29
|
+
return this.cache.step?this.cache.step:1000 / this.cache.fps;
|
|
30
|
+
}
|
|
31
|
+
start() {
|
|
32
|
+
if (!this.cache.isRunning) {
|
|
33
|
+
this.i=0;
|
|
34
|
+
this.cache.isRunning = true;
|
|
35
|
+
this.cache.startTime = Date.now();
|
|
36
|
+
this.animate();
|
|
37
|
+
}
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
pause() {
|
|
41
|
+
if (this.cache.isRunning) {
|
|
42
|
+
clearTimeout(this.cache.AnimationId);
|
|
43
|
+
this.cache.isRunning = false;
|
|
44
|
+
}
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
stop(){
|
|
48
|
+
this.pause();
|
|
49
|
+
this.i=0;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
resume(){
|
|
53
|
+
this.cache.isRunning=true;
|
|
54
|
+
this.animate();
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
startAfter(t=1000){
|
|
58
|
+
setTimeout(this.start.bind(this),t);
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
stopAfter(t=1000){
|
|
62
|
+
setTimeout(this.stop.bind(this),t);
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
animate = () => {
|
|
66
|
+
if (this.cache.isRunning) {
|
|
67
|
+
const now = Date.now();
|
|
68
|
+
const delta = now - this.cache.startTime;
|
|
69
|
+
if (delta > this.TIME_STEP) {
|
|
70
|
+
this.callback(this);
|
|
71
|
+
this.i++;
|
|
72
|
+
this.cache.startTime = now - (delta % this.TIME_STEP);
|
|
73
|
+
}
|
|
74
|
+
this.cache.AnimationId = setTimeout(this.animate, 0);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const loop = (callback, options) => new ZikoTimeLoop(callback, options);
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
//const a = loop((e) => console.log(e.i), {step:100,fps:30,t:[500,4001],start:true});
|
|
83
|
+
export {loop}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const useDebounce=(fn,delay=1000)=>{
|
|
2
|
+
let id;
|
|
3
|
+
return(...args)=>id?clearTimeout(id):setTimeout(()=>fn(...args),delay)
|
|
4
|
+
}
|
|
5
|
+
const useThrottle=(fn,delay)=>{
|
|
6
|
+
let lastTime=0;
|
|
7
|
+
return (...args)=>{
|
|
8
|
+
const now=new Date().getTime()
|
|
9
|
+
if(now-lastTime<delay)return;
|
|
10
|
+
lastTime=now;
|
|
11
|
+
fn(...args);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export{
|
|
15
|
+
useDebounce,
|
|
16
|
+
useThrottle
|
|
17
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
const Ease={
|
|
2
|
+
Linear:function(t){
|
|
3
|
+
return t;
|
|
4
|
+
},
|
|
5
|
+
InSin(t){
|
|
6
|
+
return 1 - Math.cos((t * Math.PI) / 2);
|
|
7
|
+
},
|
|
8
|
+
OutSin(t){
|
|
9
|
+
return Math.sin((t * Math.PI) / 2);
|
|
10
|
+
},
|
|
11
|
+
InOutSin(t){
|
|
12
|
+
return -(Math.cos(Math.PI * t) - 1) / 2;
|
|
13
|
+
},
|
|
14
|
+
InQuad(t){
|
|
15
|
+
return t**2;
|
|
16
|
+
},
|
|
17
|
+
OutQuad(t){
|
|
18
|
+
return 1 - Math.pow((1 - t),2)
|
|
19
|
+
},
|
|
20
|
+
InOutQuad(t){
|
|
21
|
+
return t < 0.5 ? 2 * Math.pow(t,2) : 1 - Math.pow(-2 * t + 2, 2) / 2;
|
|
22
|
+
},
|
|
23
|
+
InCubic(t){
|
|
24
|
+
return t**3;
|
|
25
|
+
},
|
|
26
|
+
OutCubic(t){
|
|
27
|
+
return 1 - Math.pow((1 - t),3)
|
|
28
|
+
},
|
|
29
|
+
InOutCubic(t){
|
|
30
|
+
return t < 0.5 ? 4 * Math.pow(t,3) : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
|
31
|
+
},
|
|
32
|
+
InQuart(t){
|
|
33
|
+
return t**4;
|
|
34
|
+
},
|
|
35
|
+
OutQuart(t){
|
|
36
|
+
return 1 - Math.pow((1 - t),4);
|
|
37
|
+
},
|
|
38
|
+
InOutQuart(t){
|
|
39
|
+
return t < 0.5 ? 8 * Math.pow(t,4) : 1 - Math.pow(-2 * t + 2, 4) / 2;
|
|
40
|
+
},
|
|
41
|
+
InQuint(t){
|
|
42
|
+
return t**5;
|
|
43
|
+
},
|
|
44
|
+
OutQuint(t){
|
|
45
|
+
return 1 - Math.pow((1 - t),5);
|
|
46
|
+
},
|
|
47
|
+
InOutQuint(t){
|
|
48
|
+
return t < 0.5 ? 16 * Math.pow(t,5) : 1 - Math.pow(-2 * t + 2, 5) / 2;
|
|
49
|
+
},
|
|
50
|
+
InExpo(t){
|
|
51
|
+
return t === 0 ? 0 : Math.pow(2, 10 * t - 10);
|
|
52
|
+
},
|
|
53
|
+
OutExpo(t){
|
|
54
|
+
return t === 1 ? 1 : 1 - Math.pow(2, -10 * t);
|
|
55
|
+
},
|
|
56
|
+
InOutExpo(t){
|
|
57
|
+
return t === 0? 0: t === 1? 1: t < 0.5 ? Math.pow(2, 20 * t - 10) / 2: (2 - Math.pow(2, -20 * t + 10)) / 2;
|
|
58
|
+
},
|
|
59
|
+
InCirc(t){
|
|
60
|
+
return 1 - Math.sqrt(1 - Math.pow(t, 2));
|
|
61
|
+
},
|
|
62
|
+
OutCirc(t){
|
|
63
|
+
return Math.sqrt(1 - Math.pow(t - 1, 2));
|
|
64
|
+
},
|
|
65
|
+
InOutCic(t){
|
|
66
|
+
return t < 0.5? (1 - Math.sqrt(1 - Math.pow(2 * t, 2))) / 2: (Math.sqrt(1 - Math.pow(-2 * t + 2, 2)) + 1) / 2;
|
|
67
|
+
},
|
|
68
|
+
Arc(t){
|
|
69
|
+
return 1 - Math.sin(Math.acos(t));
|
|
70
|
+
},
|
|
71
|
+
Back(t){
|
|
72
|
+
// To Be Changed
|
|
73
|
+
let x=1
|
|
74
|
+
return Math.pow(t, 2) * ((x + 1) * t - x);
|
|
75
|
+
},
|
|
76
|
+
Elastic(t){
|
|
77
|
+
return -2*Math.pow(2, 10 * (t - 1)) * Math.cos(20 * Math.PI * t / 3 * t);
|
|
78
|
+
},
|
|
79
|
+
InBack(t){
|
|
80
|
+
const c1 = 1.70158;
|
|
81
|
+
const c3 = c1 + 1;
|
|
82
|
+
return c3 *Math.pow(t,3)- c1 * (t**2);
|
|
83
|
+
},
|
|
84
|
+
OutBack(t){
|
|
85
|
+
const c1 = 1.70158;
|
|
86
|
+
const c3 = c1 + 1;
|
|
87
|
+
return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
|
|
88
|
+
},
|
|
89
|
+
InOutBack(t){
|
|
90
|
+
const c1 = 1.70158;
|
|
91
|
+
const c2 = c1 * 1.525;
|
|
92
|
+
return t < 0.5
|
|
93
|
+
? (Math.pow(2 * t, 2) * ((c2 + 1) * 2 * t - c2)) / 2
|
|
94
|
+
: (Math.pow(2 * t - 2, 2) * ((c2 + 1) * (t * 2 - 2) + c2) + 2) / 2;
|
|
95
|
+
},
|
|
96
|
+
InElastic(t){
|
|
97
|
+
const c4 = (2 * Math.PI) / 3;return t === 0
|
|
98
|
+
? 0
|
|
99
|
+
: t === 1
|
|
100
|
+
? 1
|
|
101
|
+
: -Math.pow(2, 10 * t - 10) * Math.sin((t * 10 - 10.75) * c4);
|
|
102
|
+
},
|
|
103
|
+
OutElastic(t){
|
|
104
|
+
const c4 = (2 * Math.PI) / 3;
|
|
105
|
+
return t === 0
|
|
106
|
+
? 0
|
|
107
|
+
: t === 1
|
|
108
|
+
? 1
|
|
109
|
+
: Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * c4) + 1;
|
|
110
|
+
},
|
|
111
|
+
InOutElastic(t){
|
|
112
|
+
const c5 = (2 * Math.PI) / 4.5;
|
|
113
|
+
return t === 0
|
|
114
|
+
? 0
|
|
115
|
+
: t === 1
|
|
116
|
+
? 1
|
|
117
|
+
: t < 0.5
|
|
118
|
+
? -(Math.pow(2, 20 * t - 10) * Math.sin((20 * t - 11.125) * c5)) / 2
|
|
119
|
+
: (Math.pow(2, -20 * t + 10) * Math.sin((20 * t - 11.125) * c5)) / 2 + 1;
|
|
120
|
+
},
|
|
121
|
+
InBounce(t){
|
|
122
|
+
return 1 - Ease.OutBounce(1-t);
|
|
123
|
+
},
|
|
124
|
+
OutBounce(t){
|
|
125
|
+
const n1 = 7.5625;
|
|
126
|
+
const d1 = 2.75;
|
|
127
|
+
if (t < 1 / d1) {
|
|
128
|
+
return n1 * t * t;
|
|
129
|
+
} else if (t < 2 / d1) {
|
|
130
|
+
return n1 * (t -= 1.5 / d1) * t + 0.75;
|
|
131
|
+
} else if (t < 2.5 / d1) {
|
|
132
|
+
return n1 * (t -= 2.25 / d1) * t + 0.9375;
|
|
133
|
+
} else {
|
|
134
|
+
return n1 * (t -= 2.625 / d1) * t + 0.984375;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
},
|
|
138
|
+
InOutBounce(t){
|
|
139
|
+
return t < 0.5
|
|
140
|
+
? (1 - Ease.OutBounce(1 - 2 * t)) / 2
|
|
141
|
+
: (1 + Ease.OutBounce(2 * t - 1)) / 2;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export default Ease
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Ease from "./ease.js";
|
|
2
|
+
const wait=(delayInMS)=>{
|
|
3
|
+
return new Promise((resolve) => setTimeout(resolve, delayInMS));
|
|
4
|
+
}
|
|
5
|
+
const timeTaken = callback => {
|
|
6
|
+
console.time('timeTaken');
|
|
7
|
+
const r = callback();
|
|
8
|
+
console.timeEnd('timeTaken');
|
|
9
|
+
return r;
|
|
10
|
+
}
|
|
11
|
+
export{
|
|
12
|
+
wait,
|
|
13
|
+
timeTaken,
|
|
14
|
+
Ease
|
|
15
|
+
}
|
|
16
|
+
export * from "./decorators.js";
|
|
17
|
+
export * from "./performance.js";
|
|
18
|
+
export * from "./ui.js"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const time_memory_Taken = (callback) => {
|
|
2
|
+
const t0 = Date.now();
|
|
3
|
+
const m0 = performance.memory.usedJSHeapSize;
|
|
4
|
+
const result = callback();
|
|
5
|
+
const t1 = Date.now();
|
|
6
|
+
const m1 = performance.memory.usedJSHeapSize;
|
|
7
|
+
const elapsedTime = t1 - t0;
|
|
8
|
+
const usedMemory = m1 - m0;
|
|
9
|
+
return {
|
|
10
|
+
elapsedTime,
|
|
11
|
+
usedMemory,
|
|
12
|
+
result
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export {time_memory_Taken}
|
|
16
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const waitForUIElm=(UIElement)=>{
|
|
2
|
+
return new Promise(resolve => {
|
|
3
|
+
if (UIElement.element) {
|
|
4
|
+
return resolve(UIElement.element);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const observer = new MutationObserver(() => {
|
|
8
|
+
if (UIElement.element) {
|
|
9
|
+
resolve(UIElement.element);
|
|
10
|
+
observer.disconnect();
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
observer.observe(document.body, {
|
|
15
|
+
childList: true,
|
|
16
|
+
subtree: true
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const waitForUIElmSync=(UIElement,timeout=2000)=>{
|
|
21
|
+
const t0=Date.now();
|
|
22
|
+
while(Date.now()-t0<timeout){
|
|
23
|
+
if(UIElement.element)return UIElement.element
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {waitForUIElm,waitForUIElmSync}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import ZikoUIElement from "../../../ZikoUIElement";
|
|
2
|
+
import { ZikoUIFlex } from "../../Flex";
|
|
3
|
+
import { ZikoHtml } from "../../../Misc";
|
|
4
|
+
class ZikoUIAccordion extends ZikoUIElement{
|
|
5
|
+
constructor(summary,content,icon="😁"){
|
|
6
|
+
super("details","Accordion")
|
|
7
|
+
this.summary=ZikoHtml("summary",summary).style({
|
|
8
|
+
fontSize:"1.1em",
|
|
9
|
+
padding:"0.625rem",
|
|
10
|
+
fontWeight:"bold",
|
|
11
|
+
listStyleType:`"${icon}"`,
|
|
12
|
+
cursor:"pointer",
|
|
13
|
+
});
|
|
14
|
+
this.summary[0].style({
|
|
15
|
+
marginLeft:"0.5em",
|
|
16
|
+
})
|
|
17
|
+
this.content=content.style({
|
|
18
|
+
margin:"0.7em",
|
|
19
|
+
});
|
|
20
|
+
this.append(this.summary,this.content);
|
|
21
|
+
this.style({
|
|
22
|
+
marginBottom:"0.7em",
|
|
23
|
+
})
|
|
24
|
+
this.render();
|
|
25
|
+
}
|
|
26
|
+
get isOpen(){
|
|
27
|
+
return this.element.open;
|
|
28
|
+
}
|
|
29
|
+
open(){
|
|
30
|
+
this.element.open=true;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
onOpen(callback){
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
close(){
|
|
37
|
+
this.element.open=true;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
onClose(callback){
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
toggle(){
|
|
44
|
+
this.element.open=!this.element.open;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
class ZikoUIAccordions extends ZikoUIFlex{
|
|
49
|
+
constructor(){
|
|
50
|
+
super();
|
|
51
|
+
}
|
|
52
|
+
addPair(controller,details){
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const Accordion=(summary,content,icon)=>new ZikoUIAccordion(summary,content,icon);
|
|
58
|
+
export{
|
|
59
|
+
Accordion
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Watch open using Mutation observer
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ZikoUIFlex } from "../../Flex";
|
|
2
|
+
class ZikoUICarousel extends ZikoUIFlex{
|
|
3
|
+
constructor(...ZikoUIElement){
|
|
4
|
+
super()
|
|
5
|
+
this.style({
|
|
6
|
+
position:"relative",
|
|
7
|
+
overflow:"hidden",
|
|
8
|
+
touchAction:"none",
|
|
9
|
+
userSelect:"none"
|
|
10
|
+
});
|
|
11
|
+
this.horizontal("space-around",0);
|
|
12
|
+
this.track = Section(...ZikoUIElement).style({ display: "inline-flex" });
|
|
13
|
+
this.track.size(this.track.children.length * 100 + "vw");
|
|
14
|
+
this.track.setTarget(this);
|
|
15
|
+
this.track.items.map((n) =>
|
|
16
|
+
n.style({ pointerEvents: "none", margin: "auto 10px" })
|
|
17
|
+
);
|
|
18
|
+
this.x0 = null;
|
|
19
|
+
this.tx = 0;
|
|
20
|
+
this.onPtrMove(e=>{
|
|
21
|
+
if(e.isDown){
|
|
22
|
+
let x = e.event.pageX;
|
|
23
|
+
let dx = x - this.x0;
|
|
24
|
+
this.track.st.translateX(
|
|
25
|
+
this.tx + dx,
|
|
26
|
+
0
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
this.onPtrDown(e=>{
|
|
31
|
+
console.log(e.event)
|
|
32
|
+
this.x0 = e.event.pageX;
|
|
33
|
+
const transformMatrix = window
|
|
34
|
+
.getComputedStyle(this.track.element)
|
|
35
|
+
.getPropertyValue("transform");
|
|
36
|
+
if (transformMatrix !== "none") {
|
|
37
|
+
this.tx = +transformMatrix.split(",")[4];
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
this.onPtrUp(e=>console.log(e.isDown));
|
|
41
|
+
this.onPtrLeave(e=>{
|
|
42
|
+
// Handle outside up
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const Carousel=(...ZikoUIElement)=>new ZikoUICarousel(...ZikoUIElement);
|
|
47
|
+
export {Carousel}
|