@kizmann/pico-js 2.0.7 → 2.0.9
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/dist/pico-js.browser.js +1 -1
- package/dist/pico-js.browser.js.map +1 -1
- package/dist/pico-js.esm.js +1 -1
- package/dist/pico-js.esm.js.map +1 -1
- package/package.json +4 -6
- package/src/dom/{DomAttribute.js → DomAttribute.ts} +40 -63
- package/src/dom/{DomBuilder.js → DomBuilder.ts} +27 -44
- package/src/dom/{DomEvent.js → DomEvent.ts} +101 -76
- package/src/dom/{DomFinder.js → DomFinder.ts} +103 -139
- package/src/dom/DomForm.ts +38 -0
- package/src/dom/{DomGlobal.js → DomGlobal.ts} +34 -51
- package/src/dom/{DomInview.js → DomInview.ts} +37 -57
- package/src/dom/DomMeta.ts +48 -0
- package/src/dom/DomObserver.ts +17 -0
- package/src/dom/{DomPopover.js → DomPopover.ts} +20 -39
- package/src/dom/{DomRectangle.js → DomRectangle.ts} +70 -87
- package/src/format/{FormatFile.js → FormatFile.ts} +12 -23
- package/src/format/{FormatOption.js → FormatOption.ts} +15 -24
- package/src/format/{FormatParam.js → FormatParam.ts} +14 -25
- package/src/format/{FormatParser.js → FormatParser.ts} +29 -39
- package/src/format/{FormatUrl.js → FormatUrl.ts} +9 -21
- package/src/index.browser.ts +32 -0
- package/src/index.esm.ts +64 -0
- package/src/now/{NowDefault.js → NowDefault.ts} +86 -121
- package/src/now/{NowFormat.js → NowFormat.ts} +23 -28
- package/src/now/{NowGrid.js → NowGrid.ts} +41 -58
- package/src/now/{NowHuman.js → NowHuman.ts} +18 -27
- package/src/now/{NowMatch.js → NowMatch.ts} +22 -28
- package/src/now/{NowRange.js → NowRange.ts} +13 -22
- package/src/now/{NowWalker.js → NowWalker.ts} +65 -71
- package/src/tool/{scope.js → scope.ts} +41 -11
- package/src/utils/{Array.js → Array.ts} +187 -152
- package/src/utils/{Cookie.js → Cookie.ts} +15 -12
- package/src/utils/{Data.js → Data.ts} +17 -17
- package/src/utils/Dom.ts +204 -0
- package/src/utils/Format.ts +48 -0
- package/src/utils/{Hash.js → Hash.ts} +20 -20
- package/src/utils/{Locale.js → Locale.ts} +21 -21
- package/src/utils/{Mixed.js → Mixed.ts} +104 -61
- package/src/utils/{Now.js → Now.ts} +68 -69
- package/src/utils/{Number.js → Number.ts} +34 -36
- package/src/utils/{Object.js → Object.ts} +68 -122
- package/src/utils/{Route.js → Route.ts} +11 -9
- package/src/utils/{Runner.js → Runner.ts} +89 -77
- package/src/utils/{Signal.js → Signal.ts} +35 -22
- package/src/utils/{String.js → String.ts} +79 -69
- package/src/wip/{Element.js → Element.ts} +2 -2
- package/src/wip/{Map.js → Map.ts} +1 -1
- package/types/dom/DomAttribute.d.ts +16 -27
- package/types/dom/DomBuilder.d.ts +6 -9
- package/types/dom/DomEvent.d.ts +19 -24
- package/types/dom/DomFinder.d.ts +38 -61
- package/types/dom/DomForm.d.ts +7 -10
- package/types/dom/DomGlobal.d.ts +8 -15
- package/types/dom/DomInview.d.ts +9 -19
- package/types/dom/DomMeta.d.ts +9 -16
- package/types/dom/DomObserver.d.ts +4 -8
- package/types/dom/DomPopover.d.ts +8 -11
- package/types/dom/DomRectangle.d.ts +21 -35
- package/types/format/FormatFile.d.ts +5 -8
- package/types/format/FormatOption.d.ts +6 -8
- package/types/format/FormatParam.d.ts +6 -9
- package/types/format/FormatParser.d.ts +10 -18
- package/types/format/FormatUrl.d.ts +5 -8
- package/types/index.esm.d.ts +25 -37
- package/types/now/NowDefault.d.ts +30 -99
- package/types/now/NowFormat.d.ts +8 -21
- package/types/now/NowGrid.d.ts +24 -46
- package/types/now/NowHuman.d.ts +10 -11
- package/types/now/NowMatch.d.ts +6 -4
- package/types/now/NowRange.d.ts +5 -8
- package/types/now/NowWalker.d.ts +6 -4
- package/types/tool/scope.d.ts +11 -3
- package/types/utils/Array.d.ts +83 -101
- package/types/utils/Cookie.d.ts +11 -8
- package/types/utils/Data.d.ts +7 -7
- package/types/utils/Dom.d.ts +63 -96
- package/types/utils/Format.d.ts +15 -28
- package/types/utils/Hash.d.ts +21 -21
- package/types/utils/Locale.d.ts +9 -9
- package/types/utils/Mixed.d.ts +19 -32
- package/types/utils/Now.d.ts +51 -56
- package/types/utils/Number.d.ts +9 -20
- package/types/utils/Object.d.ts +21 -36
- package/types/utils/Route.d.ts +5 -2
- package/types/utils/Runner.d.ts +45 -38
- package/types/utils/Signal.d.ts +16 -16
- package/types/utils/String.d.ts +40 -76
- package/src/dom/DomForm.js +0 -59
- package/src/dom/DomMeta.js +0 -68
- package/src/dom/DomObserver.js +0 -38
- package/src/index.browser.js +0 -36
- package/src/index.esm.js +0 -80
- package/src/utils/Dom.js +0 -214
- package/src/utils/Format.js +0 -62
- package/types/wip/Element.d.ts +0 -119
- package/types/wip/Map.d.ts +0 -254
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { Run,
|
|
2
|
-
import { PicoDom } from "../utils/Dom.
|
|
1
|
+
import { Run, Dom, Hash } from "../index.esm.ts";
|
|
2
|
+
import { PicoDom, PicoDomInterface } from "../utils/Dom.ts";
|
|
3
|
+
|
|
4
|
+
export interface PicoDomGlobal extends PicoDomInterface
|
|
5
|
+
{
|
|
6
|
+
//
|
|
7
|
+
}
|
|
3
8
|
|
|
4
9
|
/**
|
|
5
10
|
* @memberof PicoDom
|
|
6
11
|
*/
|
|
7
|
-
export class
|
|
12
|
+
export class PicoDomGlobal
|
|
8
13
|
{
|
|
9
14
|
/**
|
|
10
15
|
* Get document ready state
|
|
@@ -13,7 +18,7 @@ export class PicoDomGlobalStatic
|
|
|
13
18
|
*
|
|
14
19
|
* @returns {string} State string
|
|
15
20
|
*/
|
|
16
|
-
static getDomState()
|
|
21
|
+
static getDomState() : string
|
|
17
22
|
{
|
|
18
23
|
return document.readyState;
|
|
19
24
|
}
|
|
@@ -25,7 +30,7 @@ export class PicoDomGlobalStatic
|
|
|
25
30
|
*
|
|
26
31
|
* @returns {boolean} True if ready
|
|
27
32
|
*/
|
|
28
|
-
static isDomReady()
|
|
33
|
+
static isDomReady() : boolean
|
|
29
34
|
{
|
|
30
35
|
return Dom.getDomState() === 'complete';
|
|
31
36
|
}
|
|
@@ -37,7 +42,7 @@ export class PicoDomGlobalStatic
|
|
|
37
42
|
*
|
|
38
43
|
* @returns {boolean} True if complete
|
|
39
44
|
*/
|
|
40
|
-
static isDomComplete()
|
|
45
|
+
static isDomComplete() : boolean
|
|
41
46
|
{
|
|
42
47
|
let state = Dom.getDomState();
|
|
43
48
|
|
|
@@ -53,12 +58,12 @@ export class PicoDomGlobalStatic
|
|
|
53
58
|
*
|
|
54
59
|
* @example Dom.ready(cb)
|
|
55
60
|
*
|
|
56
|
-
* @param {
|
|
61
|
+
* @param {Function} cb Callback fn
|
|
57
62
|
* @param {number} [delay] Execution delay
|
|
58
63
|
* @param {number} [limit] Wait limit
|
|
59
64
|
* @returns {PicoDom} Static class
|
|
60
65
|
*/
|
|
61
|
-
static ready(cb, delay = 0, limit = 6000)
|
|
66
|
+
static ready(cb : Function, delay : number = 0, limit : number = 6000) : PicoDom
|
|
62
67
|
{
|
|
63
68
|
let [id, el, event] = [
|
|
64
69
|
Hash.make(), Dom.find(document), 'DOMContentLoaded'
|
|
@@ -70,7 +75,8 @@ export class PicoDomGlobalStatic
|
|
|
70
75
|
|
|
71
76
|
let ready = Dom.isDomReady;
|
|
72
77
|
|
|
73
|
-
if ( !
|
|
78
|
+
if ( !ready() ) {
|
|
79
|
+
// @ts-ignore
|
|
74
80
|
return (el.on(event, fn, { id }), this);
|
|
75
81
|
}
|
|
76
82
|
|
|
@@ -78,7 +84,7 @@ export class PicoDomGlobalStatic
|
|
|
78
84
|
if ( ready() ) return (fn(), true);
|
|
79
85
|
}, 10, limit);
|
|
80
86
|
|
|
81
|
-
return this;
|
|
87
|
+
return <PicoDom> <unknown> this;
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
/**
|
|
@@ -86,12 +92,12 @@ export class PicoDomGlobalStatic
|
|
|
86
92
|
*
|
|
87
93
|
* @example Dom.complete(cb)
|
|
88
94
|
*
|
|
89
|
-
* @param {
|
|
95
|
+
* @param {Function} cb Callback fn
|
|
90
96
|
* @param {number} [delay] Execution delay
|
|
91
97
|
* @param {number} [limit] Wait limit
|
|
92
98
|
* @returns {PicoDom} Static class
|
|
93
99
|
*/
|
|
94
|
-
static complete(cb, delay = 0, limit = 6000)
|
|
100
|
+
static complete(cb : Function, delay : number = 0, limit : number = 6000) : PicoDom
|
|
95
101
|
{
|
|
96
102
|
let fn = () => {
|
|
97
103
|
Run.delay(cb, delay);
|
|
@@ -103,29 +109,18 @@ export class PicoDomGlobalStatic
|
|
|
103
109
|
|
|
104
110
|
let ready = Dom.isDomComplete;
|
|
105
111
|
|
|
106
|
-
if ( !
|
|
112
|
+
if ( !ready() ) {
|
|
113
|
+
// @ts-ignore
|
|
107
114
|
return (el.on(event, fn), this);
|
|
108
115
|
}
|
|
109
116
|
|
|
110
117
|
Run.wait(() => {
|
|
111
|
-
if ( ready() )
|
|
118
|
+
if ( ready() ) fn();
|
|
112
119
|
}, 10, limit);
|
|
113
120
|
|
|
114
|
-
return this;
|
|
121
|
+
return <PicoDom> <unknown> this;
|
|
115
122
|
}
|
|
116
123
|
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
PicoDomGlobalStatic.required = () => {
|
|
120
|
-
console.error('Dom.required() is not implemented anymore.');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @memberof PicoDom
|
|
125
|
-
* @extends {PicoDom}
|
|
126
|
-
*/
|
|
127
|
-
export class PicoDomGlobalInstance
|
|
128
|
-
{
|
|
129
124
|
/**
|
|
130
125
|
* Check if node is complete
|
|
131
126
|
*
|
|
@@ -133,7 +128,7 @@ export class PicoDomGlobalInstance
|
|
|
133
128
|
*
|
|
134
129
|
* @returns {boolean} True if complete
|
|
135
130
|
*/
|
|
136
|
-
isNodeComplete()
|
|
131
|
+
isNodeComplete() : boolean
|
|
137
132
|
{
|
|
138
133
|
if ( this.el == null ) {
|
|
139
134
|
return false;
|
|
@@ -147,7 +142,7 @@ export class PicoDomGlobalInstance
|
|
|
147
142
|
return true;
|
|
148
143
|
}
|
|
149
144
|
|
|
150
|
-
return !!
|
|
145
|
+
return !!this.el.complete;
|
|
151
146
|
}
|
|
152
147
|
|
|
153
148
|
/**
|
|
@@ -155,14 +150,14 @@ export class PicoDomGlobalInstance
|
|
|
155
150
|
*
|
|
156
151
|
* @example Dom.find("img").loaded(cb)
|
|
157
152
|
*
|
|
158
|
-
* @param {
|
|
153
|
+
* @param {Function} cb Callback fn
|
|
159
154
|
* @param {number} [limit] Wait limit
|
|
160
155
|
* @returns {PicoDom} Current instance
|
|
161
156
|
*/
|
|
162
|
-
loaded(cb, limit = 6000)
|
|
157
|
+
loaded(cb : Function, limit : number = 6000) : PicoDom
|
|
163
158
|
{
|
|
164
|
-
if ( !
|
|
165
|
-
return this;
|
|
159
|
+
if ( !this.el ) {
|
|
160
|
+
return <PicoDom> <unknown> this;
|
|
166
161
|
}
|
|
167
162
|
|
|
168
163
|
let ready = this.isNodeComplete;
|
|
@@ -171,25 +166,13 @@ export class PicoDomGlobalInstance
|
|
|
171
166
|
if ( ready.call(this) ) return (cb(), true);
|
|
172
167
|
}, 10, limit);
|
|
173
168
|
|
|
174
|
-
return this;
|
|
169
|
+
return <PicoDom> <unknown> this;
|
|
175
170
|
}
|
|
176
171
|
}
|
|
177
172
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
export const PicoDomGlobalPlugin = function (self) {
|
|
183
|
-
|
|
184
|
-
Obj.each(Mix.class(PicoDomGlobalStatic), (fn, id) => {
|
|
185
|
-
self[id] = fn;
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
Obj.each(Mix.proto(PicoDomGlobalInstance), (fn, id) => {
|
|
189
|
-
self.prototype[id] = fn;
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
// self.init.push(PicoDomGlobalInstance.constructor);
|
|
173
|
+
// @ts-ignore
|
|
174
|
+
PicoDomGlobal.required = () => {
|
|
175
|
+
console.error('Dom.required() is not implemented anymore.');
|
|
176
|
+
}
|
|
193
177
|
|
|
194
|
-
|
|
195
|
-
}
|
|
178
|
+
export default PicoDomGlobal;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { Arr, Dom, Mix
|
|
2
|
-
import {
|
|
1
|
+
import { Arr, Dom, Mix } from "../index.esm.ts";
|
|
2
|
+
import { PicoDomInterface } from "../utils/Dom.ts";
|
|
3
|
+
import PicoDomFinder from "./DomFinder.js";
|
|
4
|
+
import PicoDomRectangle from "./DomRectangle.js";
|
|
5
|
+
|
|
6
|
+
export interface PicoDomInview extends PicoDomInterface,
|
|
7
|
+
PicoDomFinder,
|
|
8
|
+
PicoDomRectangle
|
|
9
|
+
{
|
|
10
|
+
//
|
|
11
|
+
}
|
|
3
12
|
|
|
4
13
|
/**
|
|
5
14
|
* @memberof PicoDom
|
|
6
15
|
*/
|
|
7
|
-
export class
|
|
16
|
+
export class PicoDomInview
|
|
8
17
|
{
|
|
9
18
|
|
|
10
19
|
/**
|
|
@@ -13,10 +22,10 @@ export class PicoDomInviewStatic
|
|
|
13
22
|
* @example Dom.inviewMaxY(".item")
|
|
14
23
|
*
|
|
15
24
|
* @param {any} options Find options
|
|
16
|
-
* @param {
|
|
25
|
+
* @param {Function} [cb] Success callback
|
|
17
26
|
* @returns {any} Found element
|
|
18
27
|
*/
|
|
19
|
-
static inviewMaxY(options, cb = null)
|
|
28
|
+
static inviewMaxY(options : any, cb : Function = null) : any
|
|
20
29
|
{
|
|
21
30
|
let defaults = {
|
|
22
31
|
boundry: null, multiple: false, threshold: 0, mode: 'ratio'
|
|
@@ -30,7 +39,7 @@ export class PicoDomInviewStatic
|
|
|
30
39
|
...defaults, ...options
|
|
31
40
|
};
|
|
32
41
|
|
|
33
|
-
if ( !
|
|
42
|
+
if ( !options.el ) {
|
|
34
43
|
throw new Error('Dom.inviewY() requires an element.');
|
|
35
44
|
}
|
|
36
45
|
|
|
@@ -38,13 +47,13 @@ export class PicoDomInviewStatic
|
|
|
38
47
|
options.threshold, options.mode, options.boundry
|
|
39
48
|
];
|
|
40
49
|
|
|
41
|
-
let fn = (el) => {
|
|
50
|
+
let fn = (el : any) => {
|
|
42
51
|
return Dom.find(el).isInviewY(...args);
|
|
43
52
|
};
|
|
44
53
|
|
|
45
54
|
let els = [];
|
|
46
55
|
|
|
47
|
-
Dom.find(options.el).each((el) => {
|
|
56
|
+
Dom.find(options.el).each((el : any) => {
|
|
48
57
|
if ( fn(el) ) (cb ? cb(el) : null, els.push(el));
|
|
49
58
|
});
|
|
50
59
|
|
|
@@ -61,10 +70,10 @@ export class PicoDomInviewStatic
|
|
|
61
70
|
* @example Dom.inviewMaxX(".item")
|
|
62
71
|
*
|
|
63
72
|
* @param {any} options Find options
|
|
64
|
-
* @param {
|
|
73
|
+
* @param {Function} [cb] Success callback
|
|
65
74
|
* @returns {any} Found element
|
|
66
75
|
*/
|
|
67
|
-
static inviewMaxX(options, cb = null)
|
|
76
|
+
static inviewMaxX(options : any, cb : Function = null) : any
|
|
68
77
|
{
|
|
69
78
|
let defaults = {
|
|
70
79
|
boundry: null, multiple: false, threshold: 0, mode: 'ratio'
|
|
@@ -78,7 +87,7 @@ export class PicoDomInviewStatic
|
|
|
78
87
|
...defaults, ...options
|
|
79
88
|
};
|
|
80
89
|
|
|
81
|
-
if ( !
|
|
90
|
+
if ( !options.el ) {
|
|
82
91
|
throw new Error('Dom.inviewX() requires an element.');
|
|
83
92
|
}
|
|
84
93
|
|
|
@@ -86,13 +95,13 @@ export class PicoDomInviewStatic
|
|
|
86
95
|
options.threshold, options.mode, options.boundry
|
|
87
96
|
];
|
|
88
97
|
|
|
89
|
-
let fn = (el) => {
|
|
98
|
+
let fn = (el : any) => {
|
|
90
99
|
return Dom.find(el).isInviewX(...args);
|
|
91
100
|
};
|
|
92
101
|
|
|
93
102
|
let els = [];
|
|
94
103
|
|
|
95
|
-
Dom.find(options.el).each((el) => {
|
|
104
|
+
Dom.find(options.el).each((el : any) => {
|
|
96
105
|
if ( fn(el) ) (cb ? cb(el) : null, els.push(el));
|
|
97
106
|
});
|
|
98
107
|
|
|
@@ -103,14 +112,6 @@ export class PicoDomInviewStatic
|
|
|
103
112
|
return Arr.first(els);
|
|
104
113
|
}
|
|
105
114
|
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @memberof PicoDom
|
|
110
|
-
* @extends {PicoDom}
|
|
111
|
-
*/
|
|
112
|
-
export class PicoDomInviewInstance
|
|
113
|
-
{
|
|
114
115
|
/**
|
|
115
116
|
* Get X view offset
|
|
116
117
|
*
|
|
@@ -118,7 +119,7 @@ export class PicoDomInviewInstance
|
|
|
118
119
|
*
|
|
119
120
|
* @returns {any} Offset object
|
|
120
121
|
*/
|
|
121
|
-
viewoffX()
|
|
122
|
+
viewoffX() : any
|
|
122
123
|
{
|
|
123
124
|
if ( this.el == null ) {
|
|
124
125
|
return { top: 0, bot: 0 };
|
|
@@ -151,9 +152,9 @@ export class PicoDomInviewInstance
|
|
|
151
152
|
* @param {any} [boundry] View boundry
|
|
152
153
|
* @returns {number} Inview pixels
|
|
153
154
|
*/
|
|
154
|
-
inviewX(boundry = null)
|
|
155
|
+
inviewX(boundry : any = null) : number
|
|
155
156
|
{
|
|
156
|
-
let { left, right } = Dom.find(boundry).viewoffY();
|
|
157
|
+
let { left, right } : any = Dom.find(boundry).viewoffY();
|
|
157
158
|
|
|
158
159
|
let [viewport, height] = [
|
|
159
160
|
Dom.win().innerHeight - right - left, this.height()
|
|
@@ -180,7 +181,7 @@ export class PicoDomInviewInstance
|
|
|
180
181
|
* @param {any} [boundry] View boundry
|
|
181
182
|
* @returns {number} Inview ratio
|
|
182
183
|
*/
|
|
183
|
-
inratioX(boundry = null)
|
|
184
|
+
inratioX(boundry : any = null) : number
|
|
184
185
|
{
|
|
185
186
|
return 1 / this.width() * this.inviewX(boundry);
|
|
186
187
|
}
|
|
@@ -195,7 +196,7 @@ export class PicoDomInviewInstance
|
|
|
195
196
|
* @param {any} [boundry] View boundry
|
|
196
197
|
* @returns {boolean} True if inview
|
|
197
198
|
*/
|
|
198
|
-
isInviewX(threshold = 0.1, mode = 'ratio', boundry = null)
|
|
199
|
+
isInviewX(threshold : number = 0.1, mode : string = 'ratio', boundry : any = null) : boolean
|
|
199
200
|
{
|
|
200
201
|
if ( mode === 'pixel' ) {
|
|
201
202
|
return this.inviewX(boundry) > threshold;
|
|
@@ -211,7 +212,7 @@ export class PicoDomInviewInstance
|
|
|
211
212
|
*
|
|
212
213
|
* @returns {any} Offset object
|
|
213
214
|
*/
|
|
214
|
-
viewoffY()
|
|
215
|
+
viewoffY() : any
|
|
215
216
|
{
|
|
216
217
|
if ( this.el == null ) {
|
|
217
218
|
return { top: 0, bottom: 0 };
|
|
@@ -244,9 +245,9 @@ export class PicoDomInviewInstance
|
|
|
244
245
|
* @param {any} [boundry] View boundry
|
|
245
246
|
* @returns {number} Inview pixels
|
|
246
247
|
*/
|
|
247
|
-
inviewY(boundry = null)
|
|
248
|
+
inviewY(boundry : any = null) : number
|
|
248
249
|
{
|
|
249
|
-
let { top, bottom } = Dom.find(boundry).viewoffY();
|
|
250
|
+
let { top, bottom } : any = Dom.find(boundry).viewoffY();
|
|
250
251
|
|
|
251
252
|
let [viewport, height] = [
|
|
252
253
|
Dom.win().innerHeight - bottom - top, this.height()
|
|
@@ -273,7 +274,7 @@ export class PicoDomInviewInstance
|
|
|
273
274
|
* @param {any} [boundry] View boundry
|
|
274
275
|
* @returns {number} Inview ratio
|
|
275
276
|
*/
|
|
276
|
-
inratioY(boundry = null)
|
|
277
|
+
inratioY(boundry : any = null) : number
|
|
277
278
|
{
|
|
278
279
|
return 1 / this.height() * this.inviewY(boundry);
|
|
279
280
|
}
|
|
@@ -288,7 +289,7 @@ export class PicoDomInviewInstance
|
|
|
288
289
|
* @param {any} [boundry] View boundry
|
|
289
290
|
* @returns {boolean} True if inview
|
|
290
291
|
*/
|
|
291
|
-
isInviewY(threshold = 0.1, mode = 'ratio', boundry = null)
|
|
292
|
+
isInviewY(threshold : number = 0.1, mode : string = 'ratio', boundry : any = null) : boolean
|
|
292
293
|
{
|
|
293
294
|
if ( mode === 'pixel' ) {
|
|
294
295
|
return this.inviewY(boundry) > threshold;
|
|
@@ -298,37 +299,16 @@ export class PicoDomInviewInstance
|
|
|
298
299
|
}
|
|
299
300
|
}
|
|
300
301
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
*/
|
|
304
|
-
PicoDomInviewInstance.prototype.inviewHeight = function (...args) {
|
|
302
|
+
// @ts-ignore
|
|
303
|
+
PicoDomInview.prototype.inviewHeight = function (...args : Parameters<typeof PicoDomInview.prototype.inviewY>) {
|
|
305
304
|
console.warn('Dom.inviewHeight() is deprecated, use Dom.inviewY() instead.');
|
|
306
305
|
return this.inviewY(...args);
|
|
307
306
|
}
|
|
308
307
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
*/
|
|
312
|
-
PicoDomInviewInstance.prototype.inviewWidth = function (...args) {
|
|
308
|
+
// @ts-ignore
|
|
309
|
+
PicoDomInview.prototype.inviewWidth = function (...args : Parameters<typeof PicoDomInview.prototype.inviewX>) {
|
|
313
310
|
console.warn('Dom.inviewWidth() is deprecated, use Dom.inviewX() instead.');
|
|
314
311
|
return this.inviewX(...args);
|
|
315
312
|
}
|
|
316
313
|
|
|
317
|
-
|
|
318
|
-
* @param {typeof PicoDom} self
|
|
319
|
-
* @returns {typeof PicoDom}
|
|
320
|
-
*/
|
|
321
|
-
export const PicoDomInviewPlugin = function (self) {
|
|
322
|
-
|
|
323
|
-
Obj.each(Mix.class(PicoDomInviewStatic), (fn, id) => {
|
|
324
|
-
self[id] = fn;
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
Obj.each(Mix.proto(PicoDomInviewInstance), (fn, id) => {
|
|
328
|
-
self.prototype[id] = fn;
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
// self.init.push(PicoDomInviewInstance.constructor);
|
|
332
|
-
|
|
333
|
-
return self;
|
|
334
|
-
}
|
|
314
|
+
export default PicoDomInview;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Dom, Locale } from "../index.esm.ts";
|
|
2
|
+
import { PicoDom, PicoDomInterface } from "../utils/Dom.ts";
|
|
3
|
+
|
|
4
|
+
export interface PicoDomMeta extends PicoDomInterface
|
|
5
|
+
{
|
|
6
|
+
//
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @memberof PicoDom
|
|
11
|
+
*/
|
|
12
|
+
export class PicoDomMeta
|
|
13
|
+
{
|
|
14
|
+
/**
|
|
15
|
+
* @type {any}
|
|
16
|
+
*/
|
|
17
|
+
static $meta : any = {};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Set document title
|
|
21
|
+
*
|
|
22
|
+
* @example Dom.setMetaTitle("Home")
|
|
23
|
+
*
|
|
24
|
+
* @param {string} value New title
|
|
25
|
+
* @param {string} [glue] Title glue
|
|
26
|
+
* @returns {PicoDom} Static class
|
|
27
|
+
*/
|
|
28
|
+
static setMetaTitle(value : string, glue : string = ':value - :title') : PicoDom
|
|
29
|
+
{
|
|
30
|
+
if ( !this.$meta.title ) {
|
|
31
|
+
this.$meta.title = Dom.doc().title;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
document.title = Locale.replace(glue, {
|
|
35
|
+
value, title: this.$meta.title
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return <PicoDom> <unknown> this;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
PicoDomMeta.title = (value : string) => {
|
|
44
|
+
console.warn('Dom.title() is deprecated, use Dom.setMetaTitle() instead.');
|
|
45
|
+
return Dom.setMetaTitle(value);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default PicoDomMeta;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Arr, Mix, Obj, Dom } from "../index.esm.ts";
|
|
2
|
+
import { PicoDom, PicoDomInterface } from "../utils/Dom.ts";
|
|
3
|
+
|
|
4
|
+
export interface PicoDomObserver extends PicoDomInterface
|
|
5
|
+
{
|
|
6
|
+
//
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @memberof PicoDom
|
|
11
|
+
*/
|
|
12
|
+
export class PicoDomObserver
|
|
13
|
+
{
|
|
14
|
+
//
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default PicoDomObserver;
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PicoDom } from "../utils/Dom.
|
|
1
|
+
import { Obj, Dom } from "../index.esm.ts";
|
|
2
|
+
import { PicoDom, PicoDomInterface } from "../utils/Dom.ts";
|
|
3
|
+
import PicoDomRectangle from "./DomRectangle.js";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export class PicoDomPopoverStatic
|
|
5
|
+
export interface PicoDomPopover extends PicoDomInterface,
|
|
6
|
+
PicoDomRectangle
|
|
8
7
|
{
|
|
9
8
|
//
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* @memberof PicoDom
|
|
14
|
-
* @extends {PicoDom}
|
|
15
13
|
*/
|
|
16
|
-
export class
|
|
14
|
+
export class PicoDomPopover
|
|
17
15
|
{
|
|
18
16
|
|
|
19
|
-
popover(target, position = 'botttom-center', options = {})
|
|
17
|
+
popover(target : any, position : string = 'botttom-center', options : any = {}) : any
|
|
20
18
|
{
|
|
21
19
|
if ( /^(top|bottom)-/.test(position) ) {
|
|
22
20
|
return this.popoverY(target, position, options);
|
|
@@ -27,7 +25,7 @@ export class PicoDomPopoverInstance
|
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
popoverY(target, position = 'bottom-center', options = {})
|
|
28
|
+
popoverY(target : any, position : string = 'bottom-center', options : any = {}) : any
|
|
31
29
|
{
|
|
32
30
|
target = Dom.find(target);
|
|
33
31
|
|
|
@@ -36,14 +34,14 @@ export class PicoDomPopoverInstance
|
|
|
36
34
|
];
|
|
37
35
|
|
|
38
36
|
if ( options.x ) {
|
|
39
|
-
rect = {...rect, left: options.x, width: 1 };
|
|
37
|
+
rect = { ...rect, left: options.x, width: 1 };
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
if ( options.y ) {
|
|
43
|
-
rect = {...rect, top: options.y, height: 1 };
|
|
41
|
+
rect = { ...rect, top: options.y, height: 1 };
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
if ( !
|
|
44
|
+
if ( !options.width ) {
|
|
47
45
|
// self.width = rect.width;
|
|
48
46
|
}
|
|
49
47
|
|
|
@@ -81,7 +79,7 @@ export class PicoDomPopoverInstance
|
|
|
81
79
|
inverse = inverse.replace(/^bottom-/, 'top-');
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
let win = {
|
|
82
|
+
let win : any = {
|
|
85
83
|
x: window.innerWidth, y: window.innerHeight
|
|
86
84
|
};
|
|
87
85
|
|
|
@@ -95,7 +93,7 @@ export class PicoDomPopoverInstance
|
|
|
95
93
|
...options, offset
|
|
96
94
|
};
|
|
97
95
|
|
|
98
|
-
if ( broken && !
|
|
96
|
+
if ( broken && !options.offset ) {
|
|
99
97
|
return this.popoverY(target, inverse, rebound);
|
|
100
98
|
}
|
|
101
99
|
|
|
@@ -122,7 +120,7 @@ export class PicoDomPopoverInstance
|
|
|
122
120
|
return { ...result, position };
|
|
123
121
|
}
|
|
124
122
|
|
|
125
|
-
popoverX(target, position = 'left-center', options = {})
|
|
123
|
+
popoverX(target : any, position : string = 'left-center', options : any = {}) : any
|
|
126
124
|
{
|
|
127
125
|
target = Dom.find(target);
|
|
128
126
|
|
|
@@ -130,7 +128,7 @@ export class PicoDomPopoverInstance
|
|
|
130
128
|
target.rect(), this.rect()
|
|
131
129
|
];
|
|
132
130
|
|
|
133
|
-
if ( !
|
|
131
|
+
if ( !options.height ) {
|
|
134
132
|
// self.height = rect.height;
|
|
135
133
|
}
|
|
136
134
|
|
|
@@ -168,7 +166,7 @@ export class PicoDomPopoverInstance
|
|
|
168
166
|
inverse = inverse.replace(/^right-/, 'left-');
|
|
169
167
|
}
|
|
170
168
|
|
|
171
|
-
let win = {
|
|
169
|
+
let win : any = {
|
|
172
170
|
x: window.innerWidth, y: window.innerHeight
|
|
173
171
|
};
|
|
174
172
|
|
|
@@ -182,7 +180,7 @@ export class PicoDomPopoverInstance
|
|
|
182
180
|
...options, offset
|
|
183
181
|
};
|
|
184
182
|
|
|
185
|
-
if ( broken && !
|
|
183
|
+
if ( broken && !options.offset ) {
|
|
186
184
|
return this.popoverX(target, inverse, rebound);
|
|
187
185
|
}
|
|
188
186
|
|
|
@@ -201,7 +199,7 @@ export class PicoDomPopoverInstance
|
|
|
201
199
|
return { ...result, position };
|
|
202
200
|
}
|
|
203
201
|
|
|
204
|
-
popoverNormalize(offset, self, rect, win)
|
|
202
|
+
popoverNormalize(offset : any, self : any, rect : any, win : any)
|
|
205
203
|
{
|
|
206
204
|
const scroll = Dom.find(document.body).scroll();
|
|
207
205
|
|
|
@@ -227,7 +225,7 @@ export class PicoDomPopoverInstance
|
|
|
227
225
|
x: offset.x + scroll.left, y: offset.y + scroll.top
|
|
228
226
|
}
|
|
229
227
|
|
|
230
|
-
Obj.each(offset, (v, k) => {
|
|
228
|
+
Obj.each(offset, (v : any, k : any) => {
|
|
231
229
|
offset[k] = Math.round(v);
|
|
232
230
|
});
|
|
233
231
|
|
|
@@ -244,21 +242,4 @@ export class PicoDomPopoverInstance
|
|
|
244
242
|
|
|
245
243
|
}
|
|
246
244
|
|
|
247
|
-
|
|
248
|
-
* @param {typeof PicoDom} self
|
|
249
|
-
* @returns {typeof PicoDom}
|
|
250
|
-
*/
|
|
251
|
-
export const PicoDomPopoverPlugin = function (self) {
|
|
252
|
-
|
|
253
|
-
Obj.each(Mix.class(PicoDomPopoverStatic), (fn, id) => {
|
|
254
|
-
self[id] = fn;
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
Obj.each(Mix.proto(PicoDomPopoverInstance), (fn, id) => {
|
|
258
|
-
self.prototype[id] = fn;
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
// self.init.push(PicoDomPopoverInstance.constructor);
|
|
262
|
-
|
|
263
|
-
return self;
|
|
264
|
-
}
|
|
245
|
+
export default PicoDomPopover;
|