nanosplash 2.2.4 → 2.3.2
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/.github/workflows/production.yml +57 -0
- package/.github/workflows/release.yml +61 -0
- package/README.md +17 -15
- package/dist/iife/nanosplash.iife.js +1 -1
- package/dist/module/Nanosplash.css +1 -0
- package/dist/module/manifest.json +6 -3
- package/dist/module/nanosplash.cjs.js +1 -1
- package/dist/module/nanosplash.es.js +244 -330
- package/docs/index.html +54 -430
- package/docs/nanosplash.iife.js +1 -1
- package/docs/style.css +1 -1
- package/docs/typedoc/assets/highlight.css +1 -50
- package/docs/typedoc/assets/main.js +2 -2
- package/docs/typedoc/assets/search.js +1 -1
- package/docs/typedoc/assets/style.css +32 -2
- package/docs/typedoc/classes/Core_Nanosplash.Nanosplash.html +1 -0
- package/docs/typedoc/index.html +1 -1
- package/docs/typedoc/modules/Core_Nanosplash.html +1 -0
- package/docs/typedoc/modules/types.html +1 -1
- package/index.html +51 -412
- package/jest.config.ts +194 -0
- package/package.json +70 -65
- package/src/Core/Nanosplash.ts +74 -0
- package/src/Core/SplashInstance.ts +154 -0
- package/src/Factory/NanosplashFactory.ts +73 -0
- package/src/Interfaces/ContextualAPIInterface.ts +8 -0
- package/src/Interfaces/IdentityInterface.ts +3 -0
- package/src/Interfaces/ImageInterface.ts +5 -0
- package/src/Interfaces/InsideInterface.ts +5 -0
- package/src/Interfaces/NanosplashInterface.ts +4 -0
- package/src/Interfaces/ProgressInterface.ts +5 -0
- package/src/Interfaces/ShowInterface.ts +5 -0
- package/src/Interfaces/WhileInterface.ts +5 -0
- package/src/main.ts +2 -6
- package/src/repositories/NanosplashRepository.ts +34 -55
- package/src/style.sass +51 -61
- package/src/types.d.ts +45 -200
- package/src/utilities/dom.spec.ts +70 -0
- package/src/utilities/dom.ts +17 -256
- package/update-all.sh +3 -0
- package/vite.iife.config.js +46 -18
- package/vite.mod.config.js +48 -12
- package/vite.site.config.js +0 -3
- package/dist/module/style.css +0 -1
- package/docs/typedoc/classes/Nanosplash.Nanosplash-1.html +0 -56
- package/docs/typedoc/classes/types.Nanosplash.html +0 -56
- package/docs/typedoc/modules/Nanosplash.html +0 -1
- package/src/Exceptions/Exception.ts +0 -12
- package/src/Exceptions/IllegalArgumentException.ts +0 -9
- package/src/Exceptions/InvalidDestinationException.ts +0 -9
- package/src/Exceptions/MissingResourceException.ts +0 -9
- package/src/Nanosplash.ts +0 -484
- package/update-latest.sh +0 -21
package/src/utilities/dom.ts
CHANGED
|
@@ -1,265 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CSSProperty,
|
|
3
|
-
HTMLElementTag,
|
|
4
|
-
MakeOptions,
|
|
5
|
-
TargetNodeObject,
|
|
6
|
-
} from 'nanosplash'
|
|
1
|
+
import {HTMLElementTag} from "../types";
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
* @param {string} cssSelector
|
|
12
|
-
* @return {Element | null}
|
|
13
|
-
*
|
|
14
|
-
* @description Returns the instance reference of whatever element in the DOM
|
|
15
|
-
* that matches the CSS selector string.
|
|
16
|
-
*/
|
|
17
|
-
export const ref = (cssSelector: string): HTMLElement | null =>
|
|
18
|
-
document.querySelector(cssSelector)
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Ref All (reference)
|
|
22
|
-
*
|
|
23
|
-
* @param {string} cssSelector
|
|
24
|
-
* @return {Element[]}
|
|
25
|
-
*
|
|
26
|
-
* @description Returns the instance references of whatever element in the DOM
|
|
27
|
-
* that matches the CSS selector string.
|
|
28
|
-
*/
|
|
29
|
-
export const refAll = (cssSelector: string): HTMLElement[] =>
|
|
30
|
-
Array.from(document.querySelectorAll(cssSelector))
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Create
|
|
34
|
-
*
|
|
35
|
-
* @param {HTMLElementTag} tag Valid HTML element tag name
|
|
36
|
-
* @param {MakeOptions} options Make options
|
|
37
|
-
* @returns {HTMLElement}
|
|
38
|
-
*
|
|
39
|
-
* @description Creates any HTML element that corresponds with the given tag.
|
|
40
|
-
* Additionally, if options are defined, it can mutate the element by adding
|
|
41
|
-
* class names, attributes, and content.
|
|
42
|
-
*/
|
|
43
|
-
export const create = (
|
|
44
|
-
tag: HTMLElementTag,
|
|
45
|
-
options?: MakeOptions
|
|
46
|
-
): HTMLElement => {
|
|
47
|
-
const element = document.createElement(tag)
|
|
48
|
-
if (options) {
|
|
49
|
-
// Element ID
|
|
50
|
-
element.id ||= options.id + ''
|
|
51
|
-
|
|
52
|
-
// Element class names
|
|
53
|
-
element.className ||= options.className + ''
|
|
54
|
-
|
|
55
|
-
// Element attributes
|
|
56
|
-
options.attributes
|
|
57
|
-
?.filter(v => v.value)
|
|
58
|
-
.forEach(({ key, value }) => setAttribute(element, key, value as string))
|
|
59
|
-
|
|
60
|
-
// Element content
|
|
61
|
-
if (options.content) {
|
|
62
|
-
if (typeof options.content === 'string') {
|
|
63
|
-
element.innerText = options.content
|
|
64
|
-
} else {
|
|
65
|
-
element.append(options.content)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return element
|
|
3
|
+
export function get<T>(selector: string): HTMLElement | T | null {
|
|
4
|
+
return document.querySelector(selector) as HTMLElement | T | null
|
|
70
5
|
}
|
|
71
6
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
node.hidden = !show
|
|
80
|
-
if (show) {
|
|
81
|
-
removeAttribute(node, 'hidden')
|
|
82
|
-
} else {
|
|
83
|
-
setAttribute(node, 'hidden', 'true')
|
|
84
|
-
}
|
|
7
|
+
export function move(source: Node, destination: Node, asFirstChild: boolean = false): void
|
|
8
|
+
{
|
|
9
|
+
if (source && destination) {
|
|
10
|
+
(destination.hasChildNodes() && asFirstChild)
|
|
11
|
+
? destination.insertBefore(source, destination.firstChild)
|
|
12
|
+
: destination.appendChild(source)
|
|
13
|
+
}
|
|
85
14
|
}
|
|
86
15
|
|
|
87
|
-
|
|
88
|
-
* Move
|
|
89
|
-
*
|
|
90
|
-
* @param {Node} node The node to append to another, as its child.
|
|
91
|
-
* @returns An object with a target node controller function. Said function
|
|
92
|
-
* will append the given node to a yet to be defined target node.
|
|
93
|
-
*
|
|
94
|
-
* @description This function will in turn append the node to another node.
|
|
95
|
-
* If the child node already is a reference to another node in the
|
|
96
|
-
* DOM, it will be moved to its new position by removing the current reference
|
|
97
|
-
* before creating the new one.
|
|
98
|
-
*
|
|
99
|
-
* @example move(node).to(targetNode) // Regular append
|
|
100
|
-
* @example mode(child).to(parent, true) // Append as first child
|
|
101
|
-
*/
|
|
102
|
-
export const move = (node: Node): TargetNodeObject<Node> => ({
|
|
103
|
-
/**
|
|
104
|
-
* @param {Node} targetNode The node in which the new node shall reside.
|
|
105
|
-
* @param {boolean} asFirstChild Whether or not the new node shall be the
|
|
106
|
-
* first child of the target node.
|
|
107
|
-
*/
|
|
108
|
-
to: (targetNode: Node, asFirstChild?: boolean): void => {
|
|
109
|
-
const children = Array.from(targetNode.childNodes)
|
|
110
|
-
const noChildren = children.length < 1
|
|
111
|
-
if (noChildren || !asFirstChild) {
|
|
112
|
-
targetNode.appendChild<Node>(node)
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
const firstChild = children[0]
|
|
116
|
-
targetNode.insertBefore(node, firstChild)
|
|
117
|
-
},
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Fit Parent Dimensions
|
|
122
|
-
*
|
|
123
|
-
* @param {HTMLElement} node The HTML element of which style to change.
|
|
124
|
-
*
|
|
125
|
-
* @description Transforms the node's dimensions and document position in order
|
|
126
|
-
* to match its parent node.
|
|
127
|
-
*/
|
|
128
|
-
export const fitToParent = (node: HTMLElement): void => {
|
|
129
|
-
const parent = node.parentNode as HTMLElement
|
|
130
|
-
if (parent) {
|
|
131
|
-
;((domRect: DOMRect) => {
|
|
132
|
-
const unit = 'px'
|
|
133
|
-
const parentIsBody = parent === document.body
|
|
134
|
-
let left, top, width, height
|
|
135
|
-
|
|
136
|
-
// Set distance from left
|
|
137
|
-
if (parentIsBody) {
|
|
138
|
-
left = scrollX + unit
|
|
139
|
-
} else {
|
|
140
|
-
left = 0 + unit
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Set distance from top
|
|
144
|
-
if (parentIsBody) {
|
|
145
|
-
top = scrollY + unit
|
|
146
|
-
} else {
|
|
147
|
-
top = 0 + unit
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Set width from parent
|
|
151
|
-
if (parentIsBody) {
|
|
152
|
-
width = '100%'
|
|
153
|
-
} else {
|
|
154
|
-
width = domRect.width + unit
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Set height from parent
|
|
158
|
-
if (parentIsBody) {
|
|
159
|
-
height = '100vh'
|
|
160
|
-
} else {
|
|
161
|
-
height = domRect.height + unit
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
setStyle(node, 'left', left)
|
|
165
|
-
setStyle(node, 'top', top)
|
|
166
|
-
setStyle(node, 'width', width)
|
|
167
|
-
setStyle(node, 'height', height)
|
|
168
|
-
})(parent.getBoundingClientRect())
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
declare global {
|
|
173
|
-
interface Window {
|
|
174
|
-
attachEvent: Function
|
|
175
|
-
}
|
|
176
|
-
interface Node {
|
|
177
|
-
attachEvent: Function
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Invoke On
|
|
183
|
-
*
|
|
184
|
-
* @param {Window | Node} dispatcher The node in which the given events
|
|
185
|
-
* are captured.
|
|
186
|
-
* @param {() => void} handler A function to be invoked when one of the given
|
|
187
|
-
* events are captured.
|
|
188
|
-
* @param {keyof WindowEventMap} events An array of event names.
|
|
189
|
-
*
|
|
190
|
-
* @example invokeOn(window, () => alert('Scroll'), ['scroll'])
|
|
191
|
-
*/
|
|
192
|
-
export const invokeOn = (
|
|
193
|
-
dispatcher: Window | Node,
|
|
194
|
-
handler: () => void,
|
|
195
|
-
events: Array<keyof WindowEventMap>
|
|
196
|
-
): void =>
|
|
197
|
-
(([addEventListenerLegacy, addEventListener]) => {
|
|
198
|
-
events.forEach(event => {
|
|
199
|
-
if (addEventListenerLegacy) {
|
|
200
|
-
addEventListenerLegacy(`on${event}`, handler)
|
|
201
|
-
} else {
|
|
202
|
-
addEventListener(event, handler, true)
|
|
203
|
-
}
|
|
204
|
-
})
|
|
205
|
-
})([dispatcher.attachEvent, dispatcher.addEventListener])
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Is Element or Node
|
|
209
|
-
*
|
|
210
|
-
* @param {any} value A value of any type.
|
|
211
|
-
* @returns {boolean}
|
|
212
|
-
*/
|
|
213
|
-
export const isElementOrNode = (value: any): boolean => {
|
|
214
|
-
return value instanceof Element || value instanceof Node
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Is Function
|
|
219
|
-
*
|
|
220
|
-
* @param {any} value A value of any type.
|
|
221
|
-
* @returns {boolean}
|
|
222
|
-
*/
|
|
223
|
-
export const isFunction = (value: any): boolean => {
|
|
224
|
-
return value && {}.toString.call(value) === '[object Function]'
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Set Style
|
|
229
|
-
*
|
|
230
|
-
* @param {HTMLElement} node An HTML element.
|
|
231
|
-
* @param {CSSProperty} prop A CSS property.
|
|
232
|
-
* @param {string} value A CSS value.
|
|
233
|
-
*
|
|
234
|
-
* @description Sets a CSS declaration on an HTML element.
|
|
235
|
-
*
|
|
236
|
-
* @example setStyle(divElement, 'color', '#FF0000')
|
|
237
|
-
*/
|
|
238
|
-
export const setStyle = (
|
|
239
|
-
node: HTMLElement,
|
|
240
|
-
prop: CSSProperty,
|
|
241
|
-
value: any
|
|
242
|
-
): void => {
|
|
243
|
-
node.style[prop as any] = value
|
|
244
|
-
}
|
|
16
|
+
export const mk = (tag: HTMLElementTag) => document.createElement(tag)
|
|
245
17
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
* @param {Element} node An element.
|
|
250
|
-
* @param {string} key The attribute name.
|
|
251
|
-
* @param {string} value The attribute value.
|
|
252
|
-
*/
|
|
253
|
-
export const setAttribute = (node: Element, key: string, value: string) => {
|
|
254
|
-
node.setAttribute(key, value)
|
|
18
|
+
export function addClass(node: HTMLElement, ...classes: string[]): void
|
|
19
|
+
{
|
|
20
|
+
node.classList.add(...classes)
|
|
255
21
|
}
|
|
256
22
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
* @param {Element} node An element.
|
|
261
|
-
* @param {string} key The attribute name.
|
|
262
|
-
*/
|
|
263
|
-
export const removeAttribute = (node: Element, key: string) => {
|
|
264
|
-
node.removeAttribute(key)
|
|
23
|
+
export function setAttr(node: HTMLElement, attribute: string, value: string): void
|
|
24
|
+
{
|
|
25
|
+
node.setAttribute(attribute, value)
|
|
265
26
|
}
|
package/update-all.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
yarn remove @types/jest @types/jsdom autoprefixer cssnano jest jsdom jest-environment-jsdom postcss sass ts-jest ts-node typedoc typescript vite
|
|
3
|
+
yarn add -D @types/jest @types/jsdom autoprefixer cssnano jest jsdom jest-environment-jsdom postcss sass ts-jest ts-node typedoc typescript vite
|
package/vite.iife.config.js
CHANGED
|
@@ -11,34 +11,62 @@ export default defineConfig({
|
|
|
11
11
|
},
|
|
12
12
|
outDir: 'dist/iife',
|
|
13
13
|
cssCodeSplit: true,
|
|
14
|
-
assetsInlineLimit: Number.MAX_SAFE_INTEGER,
|
|
15
|
-
rollupOptions: {
|
|
16
|
-
output: {
|
|
17
|
-
inlineDynamicImports: false,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
14
|
minify: 'terser',
|
|
21
15
|
terserOptions: {
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
parse: {
|
|
17
|
+
bare_returns: true,
|
|
18
|
+
},
|
|
19
|
+
compress: {
|
|
20
|
+
keep_fargs: false,
|
|
21
|
+
keep_fnames: false,
|
|
22
|
+
keep_classnames: false,
|
|
23
|
+
module: true,
|
|
24
|
+
passes: 3,
|
|
25
|
+
toplevel: true,
|
|
26
|
+
unsafe_arrows: true,
|
|
27
|
+
},
|
|
24
28
|
mangle: {
|
|
29
|
+
toplevel: true,
|
|
30
|
+
// Reserved class names
|
|
31
|
+
reserved: [],
|
|
25
32
|
properties: {
|
|
26
33
|
reserved: [
|
|
27
|
-
'
|
|
28
|
-
'
|
|
34
|
+
'ns',
|
|
35
|
+
'getId',
|
|
36
|
+
'getText',
|
|
37
|
+
'setText',
|
|
38
|
+
'getImgSrc',
|
|
39
|
+
'setImgSrc',
|
|
40
|
+
'moveTo',
|
|
41
|
+
'delete',
|
|
42
|
+
'img',
|
|
29
43
|
'show',
|
|
30
|
-
'hide',
|
|
31
|
-
'during',
|
|
32
44
|
'inside',
|
|
33
|
-
'
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'
|
|
45
|
+
'remove',
|
|
46
|
+
'progress',
|
|
47
|
+
'while',
|
|
48
|
+
'delete',
|
|
49
|
+
'hideAll',
|
|
50
|
+
'hide',
|
|
37
51
|
],
|
|
38
|
-
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
format: {
|
|
55
|
+
// wrap_iife: true
|
|
39
56
|
},
|
|
57
|
+
sourceMap: {
|
|
58
|
+
// source map options
|
|
59
|
+
},
|
|
60
|
+
ecma: 2015, // specify one of: 5, 2015, 2016, etc.
|
|
61
|
+
keep_classnames: false,
|
|
62
|
+
keep_fnames: false,
|
|
63
|
+
ie8: false,
|
|
64
|
+
module: true,
|
|
65
|
+
nameCache: null, // or specify a name cache object
|
|
66
|
+
safari10: false,
|
|
67
|
+
toplevel: true,
|
|
40
68
|
},
|
|
41
|
-
keep_classnames:
|
|
69
|
+
// keep_classnames: false,
|
|
42
70
|
manifest: true,
|
|
43
71
|
},
|
|
44
72
|
})
|
package/vite.mod.config.js
CHANGED
|
@@ -4,33 +4,69 @@ export default defineConfig({
|
|
|
4
4
|
mode: 'production',
|
|
5
5
|
build: {
|
|
6
6
|
lib: {
|
|
7
|
-
entry: 'src/Nanosplash.ts',
|
|
7
|
+
entry: 'src/Core/Nanosplash.ts',
|
|
8
8
|
name: 'Nanosplash',
|
|
9
9
|
fileName: 'nanosplash',
|
|
10
10
|
formats: ['es', 'cjs'],
|
|
11
11
|
},
|
|
12
12
|
outDir: 'dist/module',
|
|
13
|
+
cssCodeSplit: true,
|
|
13
14
|
minify: 'terser',
|
|
14
15
|
terserOptions: {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
parse: {
|
|
17
|
+
bare_returns: true,
|
|
18
|
+
},
|
|
19
|
+
compress: {
|
|
20
|
+
keep_fargs: false,
|
|
21
|
+
keep_fnames: false,
|
|
22
|
+
keep_classnames: false,
|
|
23
|
+
module: true,
|
|
24
|
+
passes: 3,
|
|
25
|
+
toplevel: true,
|
|
26
|
+
unsafe_arrows: true,
|
|
27
|
+
},
|
|
17
28
|
mangle: {
|
|
29
|
+
toplevel: true,
|
|
30
|
+
// Reserved class names
|
|
31
|
+
reserved: [],
|
|
18
32
|
properties: {
|
|
19
33
|
reserved: [
|
|
20
|
-
'
|
|
21
|
-
'
|
|
34
|
+
'ns',
|
|
35
|
+
'getId',
|
|
36
|
+
'getText',
|
|
37
|
+
'setText',
|
|
38
|
+
'getImgSrc',
|
|
39
|
+
'setImgSrc',
|
|
40
|
+
'moveTo',
|
|
41
|
+
'delete',
|
|
42
|
+
'img',
|
|
22
43
|
'show',
|
|
23
|
-
'hide',
|
|
24
|
-
'during',
|
|
25
44
|
'inside',
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
45
|
+
'remove',
|
|
46
|
+
'progress',
|
|
47
|
+
'while',
|
|
48
|
+
'delete',
|
|
49
|
+
'hideAll',
|
|
50
|
+
'hide',
|
|
29
51
|
],
|
|
30
|
-
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
format: {
|
|
55
|
+
// wrap_iife: true
|
|
31
56
|
},
|
|
57
|
+
sourceMap: {
|
|
58
|
+
// source map options
|
|
59
|
+
},
|
|
60
|
+
ecma: 2015, // specify one of: 5, 2015, 2016, etc.
|
|
61
|
+
keep_classnames: false,
|
|
62
|
+
keep_fnames: false,
|
|
63
|
+
ie8: false,
|
|
64
|
+
module: true,
|
|
65
|
+
nameCache: null, // or specify a name cache object
|
|
66
|
+
safari10: false,
|
|
67
|
+
toplevel: true,
|
|
32
68
|
},
|
|
33
|
-
keep_classnames:
|
|
69
|
+
// keep_classnames: false,
|
|
34
70
|
manifest: true,
|
|
35
71
|
},
|
|
36
72
|
})
|
package/vite.site.config.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import vue from '@vitejs/plugin-vue'
|
|
2
1
|
import { defineConfig } from 'vite'
|
|
3
|
-
import { viteSingleFile } from 'vite-plugin-singlefile'
|
|
4
2
|
|
|
5
3
|
export default defineConfig({
|
|
6
4
|
mode: 'production',
|
|
7
|
-
plugins: [vue(), viteSingleFile()],
|
|
8
5
|
build: {
|
|
9
6
|
lib: {
|
|
10
7
|
entry: 'index.html',
|
package/dist/module/style.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@-webkit-keyframes pulse{0%{transform:scale(1)}to{transform:scale(1.1)}}@keyframes pulse{0%{transform:scale(1)}to{transform:scale(1.1)}}@-webkit-keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.nanosplash-container{align-items:center;border-radius:inherit;flex-direction:column;justify-content:center;overflow:inherit;position:absolute;z-index:1}.nanosplash-container[hidden=true]{display:none}.nanosplash-container:not([hidden=true]){display:flex}.nanosplash-container[data-blur=none]:not([hidden=true])~*{filter:blur(0)}.nanosplash-container[data-blur=light]:not([hidden=true])~*{filter:blur(2px)}.nanosplash-container[data-blur=medium]:not([hidden=true])~*{filter:blur(4px)}.nanosplash-container[data-blur=heavy]:not([hidden=true])~*{filter:blur(10px)}.nanosplash-container .nanosplash-text{text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-smoothing:antialiased;-webkit-font-smoothing:antialiased;text-shadow:0 0 2px rgba(0,0,0,.2)}.nanosplash-container img.nanosplash-img{margin-bottom:40px}.nanosplash-container[data-splash-animation=pulse]>img{-webkit-animation-direction:alternate;animation-direction:alternate;-webkit-animation-duration:.3s;animation-duration:.3s;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-name:pulse;animation-name:pulse}.nanosplash-container[data-splash-animation=spin]>img{-webkit-animation-duration:.7s;animation-duration:.7s;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-name:spin;animation-name:spin;-webkit-animation-timing-function:linear;animation-timing-function:linear}body>.nanosplash-container:not([hidden=true]){height:100vh;width:100%}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default no-js"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Nanosplash | nanosplash</title><meta name="description" content="Documentation for nanosplash"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">nanosplash</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../index.html">nanosplash</a></li><li><a href="../modules/Nanosplash.html">Nanosplash</a></li><li><a href="Nanosplash.Nanosplash-1.html">Nanosplash</a></li></ul><h1>Class Nanosplash</h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
|
|
2
|
-
<p>Nanosplash</p>
|
|
3
|
-
</div><dl class="tsd-comment-tags"><dt>author</dt><dd><p>Isak K. Hauge</p>
|
|
4
|
-
</dd></dl></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">Nanosplash</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Constructors</h3><ul class="tsd-index-list"><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="Nanosplash.Nanosplash-1.html#constructor" class="tsd-kind-icon">constructor</a></li></ul></section><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class"><a href="Nanosplash.Nanosplash-1.html#configure" class="tsd-kind-icon">configure</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Nanosplash.Nanosplash-1.html#hide" class="tsd-kind-icon">hide</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Nanosplash.Nanosplash-1.html#install" class="tsd-kind-icon">install</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Nanosplash.Nanosplash-1.html#show" class="tsd-kind-icon">show</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Constructors</h2><section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class"><a name="constructor" class="tsd-anchor"></a><h3>constructor</h3><ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">new <wbr/>Nanosplash<span class="tsd-signature-symbol">(</span>config<span class="tsd-signature-symbol">?: </span><a href="../modules/types.html#Config" class="tsd-signature-type" data-tsd-kind="Type alias">Config</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="Nanosplash.Nanosplash-1.html" class="tsd-signature-type" data-tsd-kind="Class">Nanosplash</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/isakhauge/nanosplash/blob/527ce5d/src/Nanosplash.ts#L60">Nanosplash.ts:60</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
5
|
-
<p>Constructor</p>
|
|
6
|
-
</div><dl class="tsd-comment-tags"><dt>example</dt><dd><pre><code class="language-js"><span class="hl-0">// Instantiatie without config object.</span><br/><span class="hl-1">new</span><span class="hl-2"> </span><span class="hl-3">Nanosplash</span><span class="hl-2">()</span>
|
|
7
|
-
</code></pre>
|
|
8
|
-
</dd><dt>example</dt><dd><pre><code class="language-js"><span class="hl-0">// Instantiate with config object.</span><br/><span class="hl-1">new</span><span class="hl-2"> </span><span class="hl-3">Nanosplash</span><span class="hl-2">(</span><span class="hl-4">config</span><span class="hl-2">)</span>
|
|
9
|
-
</code></pre>
|
|
10
|
-
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> config: <a href="../modules/types.html#Config" class="tsd-signature-type" data-tsd-kind="Type alias">Config</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
|
|
11
|
-
<p>The configuration object.</p>
|
|
12
|
-
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="Nanosplash.Nanosplash-1.html" class="tsd-signature-type" data-tsd-kind="Class">Nanosplash</a></h4></li></ul></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="configure" class="tsd-anchor"></a><h3>configure</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">configure<span class="tsd-signature-symbol">(</span>config<span class="tsd-signature-symbol">: </span><a href="../modules/types.html#Config" class="tsd-signature-type" data-tsd-kind="Type alias">Config</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="Nanosplash.Nanosplash-1.html" class="tsd-signature-type" data-tsd-kind="Class">Nanosplash</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/isakhauge/nanosplash/blob/527ce5d/src/Nanosplash.ts#L139">Nanosplash.ts:139</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
13
|
-
<p>Configure</p>
|
|
14
|
-
</div><dl class="tsd-comment-tags"><dt>description</dt><dd><p>Mutates the existing configuration and returns the updated
|
|
15
|
-
instance.</p>
|
|
16
|
-
</dd><dt>example</dt><dd><pre><code class="language-js"><span class="hl-4">nanosplash</span><span class="hl-2">.</span><span class="hl-3">configure</span><span class="hl-2">(</span><span class="hl-4">config</span><span class="hl-2">)</span>
|
|
17
|
-
</code></pre>
|
|
18
|
-
</dd><dt>example</dt><dd><pre><code class="language-js"><span class="hl-4">window</span><span class="hl-2">.</span><span class="hl-4">loading</span><span class="hl-2">.</span><span class="hl-3">configure</span><span class="hl-2">(</span><span class="hl-4">config</span><span class="hl-2">).</span><span class="hl-3">show</span><span class="hl-2">(</span><span class="hl-4">text</span><span class="hl-2">)</span>
|
|
19
|
-
</code></pre>
|
|
20
|
-
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>config: <a href="../modules/types.html#Config" class="tsd-signature-type" data-tsd-kind="Type alias">Config</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
|
|
21
|
-
<p>The config object.</p>
|
|
22
|
-
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="Nanosplash.Nanosplash-1.html" class="tsd-signature-type" data-tsd-kind="Class">Nanosplash</a></h4><div><p>The updated instance.</p>
|
|
23
|
-
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="hide" class="tsd-anchor"></a><h3>hide</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">hide<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/isakhauge/nanosplash/blob/527ce5d/src/Nanosplash.ts#L275">Nanosplash.ts:275</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
24
|
-
<p>Hide</p>
|
|
25
|
-
</div><dl class="tsd-comment-tags"><dt>description</dt><dd><p>Hides the loading screen and moves to its default destination.
|
|
26
|
-
If no custom default destination is defined, it will move to the document
|
|
27
|
-
body.</p>
|
|
28
|
-
</dd><dt>example</dt><dd><pre><code class="language-js"><span class="hl-0">// Basic usage</span><br/><span class="hl-4">loading</span><span class="hl-2">.</span><span class="hl-3">hide</span><span class="hl-2">()</span><br/><span class="hl-0">// Use with async functions</span><br/><span class="hl-4">loading</span><span class="hl-2">.</span><span class="hl-3">show</span><span class="hl-2">(</span><span class="hl-5">'Loading ...'</span><span class="hl-2">)</span><br/><span class="hl-6">await</span><span class="hl-2"> </span><span class="hl-3">fetchStuffFromApi</span><span class="hl-2">()</span><br/><span class="hl-4">loading</span><span class="hl-2">.</span><span class="hl-3">hide</span><span class="hl-2">()</span>
|
|
29
|
-
</code></pre>
|
|
30
|
-
</dd></dl></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="install" class="tsd-anchor"></a><h3>install</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">install<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/isakhauge/nanosplash/blob/527ce5d/src/Nanosplash.ts#L111">Nanosplash.ts:111</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
31
|
-
<p>Install</p>
|
|
32
|
-
</div><dl class="tsd-comment-tags"><dt>description</dt><dd><p>Assigns itself to the Window object and sets essential event
|
|
33
|
-
listeners that responds to changes in the browser. The instance is
|
|
34
|
-
globally accessible through the property "loading".</p>
|
|
35
|
-
</dd><dt>example</dt><dd><pre><code class="language-js"><span class="hl-0">// Install</span><br/><span class="hl-2">(</span><span class="hl-1">new</span><span class="hl-2"> </span><span class="hl-3">Nanosplash</span><span class="hl-2">()).</span><span class="hl-3">install</span><span class="hl-2">()</span><br/><br/><span class="hl-0">// Access the instance globally</span><br/><span class="hl-4">loading</span><span class="hl-2">.</span><span class="hl-3">show</span><span class="hl-2">(</span><span class="hl-5">'Some text'</span><span class="hl-2">)</span>
|
|
36
|
-
</code></pre>
|
|
37
|
-
</dd></dl></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a name="show" class="tsd-anchor"></a><h3>show</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">show<span class="tsd-signature-symbol">(</span>text<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/types.html#DisplayController" class="tsd-signature-type" data-tsd-kind="Type alias">DisplayController</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/isakhauge/nanosplash/blob/527ce5d/src/Nanosplash.ts#L235">Nanosplash.ts:235</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
38
|
-
<p>Show</p>
|
|
39
|
-
</div><dl class="tsd-comment-tags"><dt>description</dt><dd><p>Shows the loading screen. Invoking the inside function will
|
|
40
|
-
display the loading screen within the constraints of the defined
|
|
41
|
-
destination.</p>
|
|
42
|
-
<p>Basic usage.</p>
|
|
43
|
-
</dd><dt>example</dt><dd><pre><code class="language-js"><span class="hl-0">// Basic usage.</span><br/><span class="hl-4">loading</span><span class="hl-2">.</span><span class="hl-3">show</span><span class="hl-2">(</span><span class="hl-4">text</span><span class="hl-2">)</span>
|
|
44
|
-
</code></pre>
|
|
45
|
-
<p>Display Nanosplash inside other DOM elements.</p>
|
|
46
|
-
</dd><dt>example</dt><dd><pre><code class="language-js"><span class="hl-0">// Show loading screen within another element using CSS selector.</span><br/><span class="hl-4">loading</span><span class="hl-2">.</span><span class="hl-3">show</span><span class="hl-2">(</span><span class="hl-4">text</span><span class="hl-2">).</span><span class="hl-3">inside</span><span class="hl-2">(</span><span class="hl-5">'#my-element'</span><span class="hl-2">)</span><br/><span class="hl-0">// Use DOM element reference.</span><br/><span class="hl-4">loading</span><span class="hl-2">.</span><span class="hl-3">show</span><span class="hl-2">(</span><span class="hl-4">text</span><span class="hl-2">).</span><span class="hl-3">inside</span><span class="hl-2">(</span><span class="hl-4">document</span><span class="hl-2">.</span><span class="hl-3">getElementById</span><span class="hl-2">(</span><span class="hl-4">id</span><span class="hl-2">))</span><br/><span class="hl-0">// Use function that returns a DOM element reference.</span><br/><span class="hl-4">loading</span><span class="hl-2">.</span><span class="hl-3">show</span><span class="hl-2">(</span><span class="hl-4">text</span><span class="hl-2">).</span><span class="hl-3">inside</span><span class="hl-2">(() </span><span class="hl-1">=></span><span class="hl-2"> </span><span class="hl-3">getDomReference</span><span class="hl-2">())</span>
|
|
47
|
-
</code></pre>
|
|
48
|
-
<p>Display Nanosplash while an asynchronous task is resolving.</p>
|
|
49
|
-
</dd><dt>example</dt><dd><pre><code class="language-js"><span class="hl-0">// Define an asynchronous task.</span><br/><span class="hl-1">const</span><span class="hl-2"> </span><span class="hl-3">task</span><span class="hl-2"> = </span><span class="hl-1">async</span><span class="hl-2"> () </span><span class="hl-1">=></span><span class="hl-2"> </span><span class="hl-6">await</span><span class="hl-2"> </span><span class="hl-3">getDataFromApi</span><span class="hl-2">()</span><br/><span class="hl-0">// Show loading screen while the task is running.</span><br/><span class="hl-4">loading</span><span class="hl-2">.</span><span class="hl-3">show</span><span class="hl-2">(</span><span class="hl-4">text</span><span class="hl-2">).</span><span class="hl-3">during</span><span class="hl-2">(</span><span class="hl-4">task</span><span class="hl-2">)</span><br/><span class="hl-4">loading</span><span class="hl-2">.</span><span class="hl-3">show</span><span class="hl-2">(</span><span class="hl-4">text</span><span class="hl-2">).</span><span class="hl-3">inside</span><span class="hl-2">(</span><span class="hl-5">'#my-element'</span><span class="hl-2">).</span><span class="hl-3">during</span><span class="hl-2">(</span><span class="hl-4">task</span><span class="hl-2">)</span>
|
|
50
|
-
</code></pre>
|
|
51
|
-
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> text: <span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
|
|
52
|
-
<p>The text that will be shown in the
|
|
53
|
-
loading screen. If undefined, Nanosplash will use the default text.</p>
|
|
54
|
-
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/types.html#DisplayController" class="tsd-signature-type" data-tsd-kind="Type alias">DisplayController</a></h4><div><p>An object with a function that controls the
|
|
55
|
-
visibility and destination of the loading screen.</p>
|
|
56
|
-
</div></li></ul></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../index.html">Modules</a></li><li class="current tsd-kind-module"><a href="../modules/Nanosplash.html">Nanosplash</a></li><li class=" tsd-kind-module"><a href="../modules/types.html">types</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-class tsd-parent-kind-module"><a href="Nanosplash.Nanosplash-1.html" class="tsd-kind-icon">Nanosplash</a><ul><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="Nanosplash.Nanosplash-1.html#constructor" class="tsd-kind-icon">constructor</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Nanosplash.Nanosplash-1.html#configure" class="tsd-kind-icon">configure</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Nanosplash.Nanosplash-1.html#hide" class="tsd-kind-icon">hide</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Nanosplash.Nanosplash-1.html#install" class="tsd-kind-icon">install</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Nanosplash.Nanosplash-1.html#show" class="tsd-kind-icon">show</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li><li class="tsd-kind-type-alias tsd-has-type-parameter"><span class="tsd-kind-icon">Type alias with type parameter</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>
|