@studiometa/ui 1.0.0-alpha.7 → 1.0.0-alpha.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/atoms/Action/Action.d.ts +4 -6
- package/atoms/Action/Action.js +25 -63
- package/atoms/Action/Action.js.map +2 -2
- package/atoms/Action/ActionEvent.d.ts +55 -0
- package/atoms/Action/ActionEvent.js +130 -0
- package/atoms/Action/ActionEvent.js.map +7 -0
- package/atoms/Data/DataBind.d.ts +1 -1
- package/atoms/Data/DataBind.js +4 -4
- package/atoms/Data/DataBind.js.map +2 -2
- package/atoms/Data/DataComputed.js +2 -2
- package/atoms/Data/DataComputed.js.map +2 -2
- package/atoms/Data/DataEffect.js +2 -2
- package/atoms/Data/DataEffect.js.map +2 -2
- package/atoms/Figure/AbstractFigure.d.ts +41 -0
- package/atoms/Figure/AbstractFigure.js +65 -0
- package/atoms/Figure/AbstractFigure.js.map +7 -0
- package/atoms/Figure/AbstractFigureDynamic.d.ts +29 -0
- package/atoms/Figure/AbstractFigureDynamic.js +48 -0
- package/atoms/Figure/AbstractFigureDynamic.js.map +7 -0
- package/atoms/Figure/Figure.d.ts +4 -35
- package/atoms/Figure/Figure.js +5 -68
- package/atoms/Figure/Figure.js.map +2 -2
- package/atoms/Figure/FigureShopify.d.ts +23 -0
- package/atoms/Figure/FigureShopify.js +38 -0
- package/atoms/Figure/FigureShopify.js.map +7 -0
- package/atoms/Figure/FigureTwicpics.d.ts +3 -19
- package/atoms/Figure/FigureTwicpics.js +10 -32
- package/atoms/Figure/FigureTwicpics.js.map +2 -2
- package/atoms/Figure/index.d.ts +1 -0
- package/atoms/Figure/index.js +1 -0
- package/atoms/Figure/index.js.map +2 -2
- package/atoms/Figure/utils.d.ts +8 -0
- package/atoms/Figure/utils.js +15 -0
- package/atoms/Figure/utils.js.map +7 -0
- package/atoms/FigureVideo/FigureVideo.js +1 -1
- package/atoms/FigureVideo/FigureVideo.js.map +1 -1
- package/atoms/FigureVideo/FigureVideoTwicpics.js +1 -1
- package/atoms/FigureVideo/FigureVideoTwicpics.js.map +1 -1
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.d.ts +1 -1
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.d.ts +1 -1
- package/decorators/withTransition.d.ts +1 -0
- package/decorators/withTransition.js +47 -23
- package/decorators/withTransition.js.map +2 -2
- package/molecules/AnchorNav/AnchorNavLink.d.ts +1 -1
- package/molecules/Menu/MenuList.d.ts +1 -1
- package/molecules/Slider/SliderDots.d.ts +1 -1
- package/organisms/Frame/FrameTarget.d.ts +1 -1
- package/package.json +1 -1
- package/primitives/Transition/Transition.d.ts +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';
|
|
2
|
+
import { AbstractFigure } from './AbstractFigure.js';
|
|
3
|
+
export interface AbstractFigureDynamicProps extends BaseProps {
|
|
4
|
+
$options: {
|
|
5
|
+
disable: boolean;
|
|
6
|
+
step: number;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* AbstractFigureDynamic class.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AbstractFigureDynamic<T extends BaseProps = BaseProps> extends AbstractFigure<T & AbstractFigureDynamicProps> {
|
|
13
|
+
/**
|
|
14
|
+
* Config.
|
|
15
|
+
*/
|
|
16
|
+
static config: BaseConfig;
|
|
17
|
+
/**
|
|
18
|
+
* Get the formatted source or the original based on the `disable` option.
|
|
19
|
+
*/
|
|
20
|
+
get original(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Format the source with dynamic parameters.
|
|
23
|
+
*/
|
|
24
|
+
formatSrc(src: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Reassign the source from the original on resize.
|
|
27
|
+
*/
|
|
28
|
+
resized(): Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AbstractFigure } from "./AbstractFigure.js";
|
|
2
|
+
import { loadImage } from "./utils.js";
|
|
3
|
+
class AbstractFigureDynamic extends AbstractFigure {
|
|
4
|
+
/**
|
|
5
|
+
* Config.
|
|
6
|
+
*/
|
|
7
|
+
static config = {
|
|
8
|
+
...AbstractFigure.config,
|
|
9
|
+
name: "AbstractFigureDynamic",
|
|
10
|
+
options: {
|
|
11
|
+
...AbstractFigure.config.options,
|
|
12
|
+
disable: Boolean,
|
|
13
|
+
step: {
|
|
14
|
+
type: Number,
|
|
15
|
+
default: 50
|
|
16
|
+
},
|
|
17
|
+
lazy: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Get the formatted source or the original based on the `disable` option.
|
|
25
|
+
*/
|
|
26
|
+
get original() {
|
|
27
|
+
return this.$options.disable ? super.original : this.formatSrc(super.original);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Format the source with dynamic parameters.
|
|
31
|
+
*/
|
|
32
|
+
/* v8 ignore next 3 */
|
|
33
|
+
formatSrc(src) {
|
|
34
|
+
return src;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reassign the source from the original on resize.
|
|
38
|
+
*/
|
|
39
|
+
async resized() {
|
|
40
|
+
const { original } = this;
|
|
41
|
+
await loadImage(original);
|
|
42
|
+
this.src = original;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
AbstractFigureDynamic
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=AbstractFigureDynamic.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/atoms/Figure/AbstractFigureDynamic.ts"],
|
|
4
|
+
"sourcesContent": ["import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport {\n withLeadingSlash,\n withoutLeadingSlash,\n withoutTrailingSlash,\n} from '@studiometa/js-toolkit/utils';\nimport { AbstractFigure } from './AbstractFigure.js';\nimport { loadImage } from './utils.js';\n\nexport interface AbstractFigureDynamicProps extends BaseProps {\n $options: {\n disable: boolean;\n step: number;\n };\n}\n\n/**\n * AbstractFigureDynamic class.\n */\nexport class AbstractFigureDynamic<T extends BaseProps = BaseProps> extends AbstractFigure<\n T & AbstractFigureDynamicProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AbstractFigure.config,\n name: 'AbstractFigureDynamic',\n options: {\n ...AbstractFigure.config.options,\n disable: Boolean,\n step: {\n type: Number,\n default: 50,\n },\n lazy: {\n type: Boolean,\n default: true,\n },\n },\n };\n\n /**\n * Get the formatted source or the original based on the `disable` option.\n */\n get original() {\n return this.$options.disable ? super.original : this.formatSrc(super.original);\n }\n\n /**\n * Format the source with dynamic parameters.\n */\n /* v8 ignore next 3 */\n formatSrc(src: string): string {\n return src;\n }\n\n /**\n * Reassign the source from the original on resize.\n */\n async resized() {\n const { original } = this;\n await loadImage(original);\n this.src = original;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAYnB,MAAM,8BAA+D,eAE1E;AAAA;AAAA;AAAA;AAAA,EAIA,OAAO,SAAqB;AAAA,IAC1B,GAAG,eAAe;AAAA,IAClB,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG,eAAe,OAAO;AAAA,MACzB,SAAS;AAAA,MACT,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,WAAW;AACb,WAAO,KAAK,SAAS,UAAU,MAAM,WAAW,KAAK,UAAU,MAAM,QAAQ;AAAA,EAC/E;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,KAAqB;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAU;AACd,UAAM,EAAE,SAAS,IAAI;AACrB,UAAM,UAAU,QAAQ;AACxB,SAAK,MAAM;AAAA,EACb;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/atoms/Figure/Figure.d.ts
CHANGED
|
@@ -1,49 +1,18 @@
|
|
|
1
1
|
import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
img: HTMLImageElement;
|
|
6
|
-
};
|
|
7
|
-
$options: {
|
|
8
|
-
lazy: boolean;
|
|
9
|
-
};
|
|
2
|
+
import { AbstractFigure } from './AbstractFigure.js';
|
|
3
|
+
import type { AbstractFigureProps } from './AbstractFigure.js';
|
|
4
|
+
export interface FigureProps extends AbstractFigureProps {
|
|
10
5
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Load the given image.
|
|
13
|
-
*/
|
|
14
|
-
export declare function loadImage(src: string): Promise<HTMLImageElement>;
|
|
15
|
-
declare const Figure_base: import("@studiometa/js-toolkit").BaseDecorator<import("@studiometa/js-toolkit").WithMountWhenInViewInterface, Transition<BaseProps>, import("@studiometa/js-toolkit").WithMountWhenInViewProps>;
|
|
16
6
|
/**
|
|
17
7
|
* Figure class.
|
|
18
8
|
*/
|
|
19
|
-
export declare class Figure<T extends BaseProps = BaseProps> extends
|
|
9
|
+
export declare class Figure<T extends BaseProps = BaseProps> extends AbstractFigure<T> {
|
|
20
10
|
/**
|
|
21
11
|
* Config.
|
|
22
12
|
*/
|
|
23
13
|
static config: BaseConfig;
|
|
24
|
-
/**
|
|
25
|
-
* Get the transition target.
|
|
26
|
-
*/
|
|
27
|
-
get target(): HTMLImageElement;
|
|
28
|
-
/**
|
|
29
|
-
* Get the image source.
|
|
30
|
-
*/
|
|
31
|
-
get src(): string;
|
|
32
|
-
/**
|
|
33
|
-
* Set the image source.
|
|
34
|
-
*/
|
|
35
|
-
set src(value: string);
|
|
36
|
-
/**
|
|
37
|
-
* Get the original source.
|
|
38
|
-
*/
|
|
39
|
-
get original(): string;
|
|
40
|
-
/**
|
|
41
|
-
* Load on mount.
|
|
42
|
-
*/
|
|
43
|
-
mounted(): Promise<void>;
|
|
44
14
|
/**
|
|
45
15
|
* Terminate the component on load.
|
|
46
16
|
*/
|
|
47
17
|
onLoad(): void;
|
|
48
18
|
}
|
|
49
|
-
export {};
|
package/atoms/Figure/Figure.js
CHANGED
|
@@ -1,74 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function loadImage(src) {
|
|
4
|
-
return new Promise((resolve) => {
|
|
5
|
-
const img = new Image();
|
|
6
|
-
img.addEventListener("load", () => resolve(img));
|
|
7
|
-
img.src = src;
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
class Figure extends withMountWhenInView(
|
|
11
|
-
Transition,
|
|
12
|
-
{
|
|
13
|
-
threshold: [0, 1]
|
|
14
|
-
}
|
|
15
|
-
) {
|
|
1
|
+
import { AbstractFigure } from "./AbstractFigure.js";
|
|
2
|
+
class Figure extends AbstractFigure {
|
|
16
3
|
/**
|
|
17
4
|
* Config.
|
|
18
5
|
*/
|
|
19
6
|
static config = {
|
|
20
|
-
...
|
|
21
|
-
name: "Figure"
|
|
22
|
-
emits: ["load"],
|
|
23
|
-
refs: ["img"],
|
|
24
|
-
options: {
|
|
25
|
-
...Transition.config.options,
|
|
26
|
-
lazy: Boolean
|
|
27
|
-
}
|
|
7
|
+
...AbstractFigure.config,
|
|
8
|
+
name: "Figure"
|
|
28
9
|
};
|
|
29
|
-
/**
|
|
30
|
-
* Get the transition target.
|
|
31
|
-
*/
|
|
32
|
-
get target() {
|
|
33
|
-
return this.$refs.img;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Get the image source.
|
|
37
|
-
*/
|
|
38
|
-
get src() {
|
|
39
|
-
return this.$refs.img.src;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Set the image source.
|
|
43
|
-
*/
|
|
44
|
-
set src(value) {
|
|
45
|
-
this.$refs.img.src = value;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get the original source.
|
|
49
|
-
*/
|
|
50
|
-
get original() {
|
|
51
|
-
return this.$refs.img.dataset.src;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Load on mount.
|
|
55
|
-
*/
|
|
56
|
-
async mounted() {
|
|
57
|
-
const { img } = this.$refs;
|
|
58
|
-
if (!img) {
|
|
59
|
-
throw new Error("[Figure] The `img` ref is required.");
|
|
60
|
-
}
|
|
61
|
-
if (!(img instanceof HTMLImageElement)) {
|
|
62
|
-
throw new Error("[Figure] The `img` ref must be an `<img>` element.");
|
|
63
|
-
}
|
|
64
|
-
const src = this.original;
|
|
65
|
-
if (this.$options.lazy && src && src !== this.src) {
|
|
66
|
-
await loadImage(src);
|
|
67
|
-
this.src = src;
|
|
68
|
-
this.enter();
|
|
69
|
-
this.$emit("load");
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
10
|
/**
|
|
73
11
|
* Terminate the component on load.
|
|
74
12
|
*/
|
|
@@ -77,7 +15,6 @@ class Figure extends withMountWhenInView(
|
|
|
77
15
|
}
|
|
78
16
|
}
|
|
79
17
|
export {
|
|
80
|
-
Figure
|
|
81
|
-
loadImage
|
|
18
|
+
Figure
|
|
82
19
|
};
|
|
83
20
|
//# sourceMappingURL=Figure.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/ui/atoms/Figure/Figure.ts"],
|
|
4
|
-
"sourcesContent": ["import { withMountWhenInView } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { withMountWhenInView } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { AbstractFigure } from './AbstractFigure.js';\nimport type { AbstractFigureProps } from './AbstractFigure.js';\n\nexport interface FigureProps extends AbstractFigureProps {}\n\n/**\n * Figure class.\n */\nexport class Figure<T extends BaseProps = BaseProps> extends AbstractFigure<T> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AbstractFigure.config,\n name: 'Figure',\n };\n\n /**\n * Terminate the component on load.\n */\n onLoad() {\n this.$terminate();\n }\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,sBAAsB;AAQxB,MAAM,eAAgD,eAAkB;AAAA;AAAA;AAAA;AAAA,EAI7E,OAAO,SAAqB;AAAA,IAC1B,GAAG,eAAe;AAAA,IAClB,MAAM;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,SAAS;AACP,SAAK,WAAW;AAAA,EAClB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';
|
|
2
|
+
import { AbstractFigureDynamic } from './AbstractFigureDynamic.js';
|
|
3
|
+
export interface FigureShopifyProps extends BaseProps {
|
|
4
|
+
$options: {
|
|
5
|
+
crop?: 'top' | 'left' | 'right' | 'bottom' | 'center';
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Figure class.
|
|
10
|
+
*
|
|
11
|
+
* Manager lazyloading image sources.
|
|
12
|
+
*/
|
|
13
|
+
export declare class FigureShopify<T extends BaseProps = BaseProps> extends AbstractFigureDynamic<T & FigureShopifyProps> {
|
|
14
|
+
/**
|
|
15
|
+
* Config.
|
|
16
|
+
*/
|
|
17
|
+
static config: BaseConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Format the source for Shopify CDN API.
|
|
20
|
+
* @see https://shopify.dev/docs/api/liquid/filters/image_url
|
|
21
|
+
*/
|
|
22
|
+
formatSrc(src: string): string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AbstractFigureDynamic } from "./AbstractFigureDynamic.js";
|
|
2
|
+
import { normalizeSize } from "./utils.js";
|
|
3
|
+
class FigureShopify extends AbstractFigureDynamic {
|
|
4
|
+
/**
|
|
5
|
+
* Config.
|
|
6
|
+
*/
|
|
7
|
+
static config = {
|
|
8
|
+
...AbstractFigureDynamic.config,
|
|
9
|
+
name: "FigureShopify",
|
|
10
|
+
options: {
|
|
11
|
+
...AbstractFigureDynamic.config.options,
|
|
12
|
+
crop: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: null
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Format the source for Shopify CDN API.
|
|
20
|
+
* @see https://shopify.dev/docs/api/liquid/filters/image_url
|
|
21
|
+
*/
|
|
22
|
+
formatSrc(src) {
|
|
23
|
+
const { crop, step } = this.$options;
|
|
24
|
+
const url = new URL(src, "https://localhost");
|
|
25
|
+
const width = normalizeSize(this.$refs.img.offsetWidth, step) * window.devicePixelRatio;
|
|
26
|
+
const height = normalizeSize(this.$refs.img.offsetHeight, step) * window.devicePixelRatio;
|
|
27
|
+
url.searchParams.set("width", String(width));
|
|
28
|
+
url.searchParams.set("height", String(height));
|
|
29
|
+
if (crop) {
|
|
30
|
+
url.searchParams.set("crop", this.$options.crop);
|
|
31
|
+
}
|
|
32
|
+
return url.toString();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
FigureShopify
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=FigureShopify.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/atoms/Figure/FigureShopify.ts"],
|
|
4
|
+
"sourcesContent": ["import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { AbstractFigureDynamic } from './AbstractFigureDynamic.js';\nimport { normalizeSize } from './utils.js';\n\nexport interface FigureShopifyProps extends BaseProps {\n $options: {\n crop?: 'top' | 'left' | 'right' | 'bottom' | 'center';\n };\n}\n\n/**\n * Figure class.\n *\n * Manager lazyloading image sources.\n */\nexport class FigureShopify<T extends BaseProps = BaseProps> extends AbstractFigureDynamic<\n T & FigureShopifyProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AbstractFigureDynamic.config,\n name: 'FigureShopify',\n options: {\n ...AbstractFigureDynamic.config.options,\n crop: {\n type: String,\n default: null,\n },\n },\n };\n\n /**\n * Format the source for Shopify CDN API.\n * @see https://shopify.dev/docs/api/liquid/filters/image_url\n */\n formatSrc(src: string): string {\n const { crop, step } = this.$options;\n\n const url = new URL(src, 'https://localhost');\n const width = normalizeSize(this.$refs.img.offsetWidth, step) * window.devicePixelRatio;\n const height = normalizeSize(this.$refs.img.offsetHeight, step) * window.devicePixelRatio;\n\n url.searchParams.set('width', String(width));\n url.searchParams.set('height', String(height));\n\n if (crop) {\n url.searchParams.set('crop', this.$options.crop);\n }\n\n return url.toString();\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAavB,MAAM,sBAAuD,sBAElE;AAAA;AAAA;AAAA;AAAA,EAIA,OAAO,SAAqB;AAAA,IAC1B,GAAG,sBAAsB;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG,sBAAsB,OAAO;AAAA,MAChC,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,KAAqB;AAC7B,UAAM,EAAE,MAAM,KAAK,IAAI,KAAK;AAE5B,UAAM,MAAM,IAAI,IAAI,KAAK,mBAAmB;AAC5C,UAAM,QAAQ,cAAc,KAAK,MAAM,IAAI,aAAa,IAAI,IAAI,OAAO;AACvE,UAAM,SAAS,cAAc,KAAK,MAAM,IAAI,cAAc,IAAI,IAAI,OAAO;AAEzE,QAAI,aAAa,IAAI,SAAS,OAAO,KAAK,CAAC;AAC3C,QAAI,aAAa,IAAI,UAAU,OAAO,MAAM,CAAC;AAE7C,QAAI,MAAM;AACR,UAAI,aAAa,IAAI,QAAQ,KAAK,SAAS,IAAI;AAAA,IACjD;AAEA,WAAO,IAAI,SAAS;AAAA,EACtB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';
|
|
2
|
-
import {
|
|
2
|
+
import { AbstractFigureDynamic } from './AbstractFigureDynamic.js';
|
|
3
3
|
export interface FigureTwicpicsProps extends BaseProps {
|
|
4
4
|
$options: {
|
|
5
5
|
transform: string;
|
|
6
6
|
domain: string;
|
|
7
7
|
path: string;
|
|
8
|
-
step: number;
|
|
9
8
|
mode: string;
|
|
10
9
|
dpr: boolean;
|
|
11
10
|
};
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* Manager lazyloading image sources.
|
|
13
|
+
* FigureTwicpics class.
|
|
17
14
|
*/
|
|
18
|
-
export declare class FigureTwicpics<T extends BaseProps = BaseProps> extends
|
|
15
|
+
export declare class FigureTwicpics<T extends BaseProps = BaseProps> extends AbstractFigureDynamic<T & FigureTwicpicsProps> {
|
|
19
16
|
/**
|
|
20
17
|
* Config.
|
|
21
18
|
*/
|
|
@@ -28,11 +25,6 @@ export declare class FigureTwicpics<T extends BaseProps = BaseProps> extends Fig
|
|
|
28
25
|
* Get the Twicpics domain.
|
|
29
26
|
*/
|
|
30
27
|
get domain(): string;
|
|
31
|
-
/**
|
|
32
|
-
* Get formatted original source.
|
|
33
|
-
* If `disable` option is `true` returns the original src.
|
|
34
|
-
*/
|
|
35
|
-
get original(): string;
|
|
36
28
|
/**
|
|
37
29
|
* Get the current device pixel ratio
|
|
38
30
|
* Returns 1 if user agent is considered as a bot.
|
|
@@ -43,12 +35,4 @@ export declare class FigureTwicpics<T extends BaseProps = BaseProps> extends Fig
|
|
|
43
35
|
* Format the source for Twicpics.
|
|
44
36
|
*/
|
|
45
37
|
formatSrc(src: string): string;
|
|
46
|
-
/**
|
|
47
|
-
* Reassign the source from the original on resize.
|
|
48
|
-
*/
|
|
49
|
-
resized(): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Do not terminate on image load as we need to set the src on resize.
|
|
52
|
-
*/
|
|
53
|
-
onLoad(): void;
|
|
54
38
|
}
|
|
@@ -3,21 +3,18 @@ import {
|
|
|
3
3
|
withoutLeadingSlash,
|
|
4
4
|
withoutTrailingSlash
|
|
5
5
|
} from "@studiometa/js-toolkit/utils";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const { step } = that.$options;
|
|
9
|
-
return Math.ceil(that.$refs.img[prop] / step) * step;
|
|
10
|
-
}
|
|
6
|
+
import { AbstractFigureDynamic } from "./AbstractFigureDynamic.js";
|
|
7
|
+
import { normalizeSize } from "./utils.js";
|
|
11
8
|
const isBot = /bot|crawl|slurp|spider/i.test(navigator.userAgent);
|
|
12
|
-
class FigureTwicpics extends
|
|
9
|
+
class FigureTwicpics extends AbstractFigureDynamic {
|
|
13
10
|
/**
|
|
14
11
|
* Config.
|
|
15
12
|
*/
|
|
16
13
|
static config = {
|
|
17
|
-
...
|
|
14
|
+
...AbstractFigureDynamic.config,
|
|
18
15
|
name: "FigureTwicpics",
|
|
19
16
|
options: {
|
|
20
|
-
...
|
|
17
|
+
...AbstractFigureDynamic.config.options,
|
|
21
18
|
transform: String,
|
|
22
19
|
domain: String,
|
|
23
20
|
path: String,
|
|
@@ -46,15 +43,7 @@ class FigureTwicpics extends Figure {
|
|
|
46
43
|
* Get the Twicpics domain.
|
|
47
44
|
*/
|
|
48
45
|
get domain() {
|
|
49
|
-
|
|
50
|
-
return url.host;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Get formatted original source.
|
|
54
|
-
* If `disable` option is `true` returns the original src.
|
|
55
|
-
*/
|
|
56
|
-
get original() {
|
|
57
|
-
return this.$options.disable ? super.original : this.formatSrc(super.original);
|
|
46
|
+
return this.$options.domain || new URL(this.$refs.img.dataset.src).host;
|
|
58
47
|
}
|
|
59
48
|
/**
|
|
60
49
|
* Get the current device pixel ratio
|
|
@@ -71,33 +60,22 @@ class FigureTwicpics extends Figure {
|
|
|
71
60
|
* Format the source for Twicpics.
|
|
72
61
|
*/
|
|
73
62
|
formatSrc(src) {
|
|
63
|
+
const { transform, mode, step } = this.$options;
|
|
74
64
|
const url = new URL(src, "https://localhost");
|
|
75
65
|
url.host = this.domain;
|
|
76
66
|
url.port = "";
|
|
77
67
|
if (this.path && !url.pathname.startsWith(withLeadingSlash(this.path))) {
|
|
78
68
|
url.pathname = `/${this.path}${url.pathname}`;
|
|
79
69
|
}
|
|
80
|
-
const width = normalizeSize(this,
|
|
81
|
-
const height = normalizeSize(this,
|
|
70
|
+
const width = normalizeSize(this.$refs.img.offsetWidth, step) * this.devicePixelRatio;
|
|
71
|
+
const height = normalizeSize(this.$refs.img.offsetHeight, step) * this.devicePixelRatio;
|
|
82
72
|
url.searchParams.set(
|
|
83
73
|
"twic",
|
|
84
|
-
["v1",
|
|
74
|
+
["v1", transform, `${mode}=${width}x${height}`].filter(Boolean).join("/")
|
|
85
75
|
);
|
|
86
76
|
url.search = decodeURIComponent(url.search);
|
|
87
77
|
return url.toString();
|
|
88
78
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Reassign the source from the original on resize.
|
|
91
|
-
*/
|
|
92
|
-
async resized() {
|
|
93
|
-
const { src } = await loadImage(this.original);
|
|
94
|
-
this.src = src;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Do not terminate on image load as we need to set the src on resize.
|
|
98
|
-
*/
|
|
99
|
-
onLoad() {
|
|
100
|
-
}
|
|
101
79
|
}
|
|
102
80
|
export {
|
|
103
81
|
FigureTwicpics
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/ui/atoms/Figure/FigureTwicpics.ts"],
|
|
4
|
-
"sourcesContent": ["import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport {\n withLeadingSlash,\n withoutLeadingSlash,\n withoutTrailingSlash,\n} from '@studiometa/js-toolkit/utils';\nimport {
|
|
5
|
-
"mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,
|
|
4
|
+
"sourcesContent": ["import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport {\n withLeadingSlash,\n withoutLeadingSlash,\n withoutTrailingSlash,\n} from '@studiometa/js-toolkit/utils';\nimport { AbstractFigureDynamic } from './AbstractFigureDynamic.js';\nimport { normalizeSize } from './utils.js';\n\nexport interface FigureTwicpicsProps extends BaseProps {\n $options: {\n transform: string;\n domain: string;\n path: string;\n mode: string;\n dpr: boolean;\n };\n}\n\n/**\n * Determine if the user agent is a bot or not.\n */\nconst isBot = /bot|crawl|slurp|spider/i.test(navigator.userAgent);\n\n/**\n * FigureTwicpics class.\n */\nexport class FigureTwicpics<T extends BaseProps = BaseProps> extends AbstractFigureDynamic<\n T & FigureTwicpicsProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AbstractFigureDynamic.config,\n name: 'FigureTwicpics',\n options: {\n ...AbstractFigureDynamic.config.options,\n transform: String,\n domain: String,\n path: String,\n disable: Boolean,\n step: {\n type: Number,\n default: 50,\n },\n mode: {\n type: String,\n default: 'cover',\n },\n dpr: {\n type: Boolean,\n default: true,\n },\n },\n };\n\n /**\n * Get the Twicpics path.\n */\n get path(): string {\n return withoutTrailingSlash(withoutLeadingSlash(this.$options.path));\n }\n\n /**\n * Get the Twicpics domain.\n */\n get domain(): string {\n return this.$options.domain || new URL(this.$refs.img.dataset.src).host;\n }\n\n /**\n * Get the current device pixel ratio\n * Returns 1 if user agent is considered as a bot.\n * Returns 1 if disabled by the `data-option-no-dpr` attribute.\n */\n get devicePixelRatio() {\n if (!this.$options.dpr || isBot) {\n return 1;\n }\n\n return window.devicePixelRatio;\n }\n\n /**\n * Format the source for Twicpics.\n */\n formatSrc(src: string): string {\n const { transform, mode, step } = this.$options;\n\n const url = new URL(src, 'https://localhost');\n url.host = this.domain;\n url.port = '';\n\n if (this.path && !url.pathname.startsWith(withLeadingSlash(this.path))) {\n url.pathname = `/${this.path}${url.pathname}`;\n }\n\n const width = normalizeSize(this.$refs.img.offsetWidth, step) * this.devicePixelRatio;\n const height = normalizeSize(this.$refs.img.offsetHeight, step) * this.devicePixelRatio;\n\n url.searchParams.set(\n 'twic',\n ['v1', transform, `${mode}=${width}x${height}`].filter(Boolean).join('/'),\n );\n\n url.search = decodeURIComponent(url.search);\n\n return url.toString();\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAe9B,MAAM,QAAQ,0BAA0B,KAAK,UAAU,SAAS;AAKzD,MAAM,uBAAwD,sBAEnE;AAAA;AAAA;AAAA;AAAA,EAIA,OAAO,SAAqB;AAAA,IAC1B,GAAG,sBAAsB;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG,sBAAsB,OAAO;AAAA,MAChC,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA,KAAK;AAAA,QACH,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,OAAe;AACjB,WAAO,qBAAqB,oBAAoB,KAAK,SAAS,IAAI,CAAC;AAAA,EACrE;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,SAAiB;AACnB,WAAO,KAAK,SAAS,UAAU,IAAI,IAAI,KAAK,MAAM,IAAI,QAAQ,GAAG,EAAE;AAAA,EACrE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,mBAAmB;AACrB,QAAI,CAAC,KAAK,SAAS,OAAO,OAAO;AAC/B,aAAO;AAAA,IACT;AAEA,WAAO,OAAO;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,KAAqB;AAC7B,UAAM,EAAE,WAAW,MAAM,KAAK,IAAI,KAAK;AAEvC,UAAM,MAAM,IAAI,IAAI,KAAK,mBAAmB;AAC5C,QAAI,OAAO,KAAK;AAChB,QAAI,OAAO;AAEX,QAAI,KAAK,QAAQ,CAAC,IAAI,SAAS,WAAW,iBAAiB,KAAK,IAAI,CAAC,GAAG;AACtE,UAAI,WAAW,IAAI,KAAK,IAAI,GAAG,IAAI,QAAQ;AAAA,IAC7C;AAEA,UAAM,QAAQ,cAAc,KAAK,MAAM,IAAI,aAAa,IAAI,IAAI,KAAK;AACrE,UAAM,SAAS,cAAc,KAAK,MAAM,IAAI,cAAc,IAAI,IAAI,KAAK;AAEvE,QAAI,aAAa;AAAA,MACf;AAAA,MACA,CAAC,MAAM,WAAW,GAAG,IAAI,IAAI,KAAK,IAAI,MAAM,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,IAC1E;AAEA,QAAI,SAAS,mBAAmB,IAAI,MAAM;AAE1C,WAAO,IAAI,SAAS;AAAA,EACtB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/atoms/Figure/index.d.ts
CHANGED
package/atoms/Figure/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/ui/atoms/Figure/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Figure.js';\nexport * from './FigureTwicpics.js';\n"],
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from './Figure.js';\nexport * from './FigureTwicpics.js';\nexport * from './FigureShopify.js';\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function loadImage(src) {
|
|
2
|
+
return new Promise((resolve) => {
|
|
3
|
+
const img = new Image();
|
|
4
|
+
img.addEventListener("load", () => resolve(img));
|
|
5
|
+
img.src = src;
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
function normalizeSize(size, step) {
|
|
9
|
+
return Math.ceil(size / step) * step;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
loadImage,
|
|
13
|
+
normalizeSize
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/atoms/Figure/utils.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Load the given image.\n */\nexport function loadImage(src: string): Promise<HTMLImageElement> {\n return new Promise((resolve) => {\n const img = new Image();\n img.addEventListener('load', () => resolve(img));\n img.src = src;\n });\n}\n\n/**\n * Normalize a size to the given step.\n */\nexport function normalizeSize(size:number, step:number): number {\n return Math.ceil(size / step) * step;\n}\n"],
|
|
5
|
+
"mappings": "AAGO,SAAS,UAAU,KAAwC;AAChE,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,MAAM,IAAI,MAAM;AACtB,QAAI,iBAAiB,QAAQ,MAAM,QAAQ,GAAG,CAAC;AAC/C,QAAI,MAAM;AAAA,EACZ,CAAC;AACH;AAKO,SAAS,cAAc,MAAa,MAAqB;AAC9D,SAAO,KAAK,KAAK,OAAO,IAAI,IAAI;AAClC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { withMountWhenInView } from "@studiometa/js-toolkit";
|
|
2
2
|
import { Transition } from "../../primitives/index.js";
|
|
3
|
-
import { loadImage } from "../
|
|
3
|
+
import { loadImage } from "../Figure/utils.js";
|
|
4
4
|
class FigureVideo extends withMountWhenInView(
|
|
5
5
|
Transition,
|
|
6
6
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/ui/atoms/FigureVideo/FigureVideo.ts"],
|
|
4
|
-
"sourcesContent": ["import { withMountWhenInView } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { Transition } from '../../primitives/index.js';\nimport { loadImage } from '../
|
|
4
|
+
"sourcesContent": ["import { withMountWhenInView } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { Transition } from '../../primitives/index.js';\nimport { loadImage } from '../Figure/utils.js';\n\nexport interface FigureVideoProps extends BaseProps {\n $refs: {\n video: HTMLVideoElement;\n };\n $options: {\n lazy: boolean;\n };\n}\n\n/**\n * FigureVideo class.\n */\nexport class FigureVideo<T extends BaseProps = BaseProps> extends withMountWhenInView<Transition>(\n Transition,\n {\n threshold: [0, 1],\n },\n)<T & FigureVideoProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...Transition.config,\n name: 'FigureVideo',\n emits: ['load'],\n refs: ['video'],\n options: {\n ...Transition.config.options,\n lazy: Boolean,\n },\n };\n\n /**\n * Get the transition target.\n */\n get target(): HTMLVideoElement {\n return this.$refs.video;\n }\n\n /**\n * Get the video sources.\n */\n get sources(): Array<HTMLSourceElement> {\n return Array.from(this.$refs.video.querySelectorAll('source'));\n }\n\n /**\n * Load poster\n */\n loadPoster(): Promise<void|HTMLImageElement> {\n const { video } = this.$refs;\n\n if (!video.dataset.poster) {\n return Promise.resolve();\n }\n\n return loadImage(video.dataset.poster).then(() => {\n video.poster = video.dataset.poster;\n this.$log('fresh poster loaded');\n })\n }\n\n /**\n * Load sources\n * @returns {Promise}\n */\n loadSources(): Promise<void> {\n const { video } = this.$refs;\n\n this.sources.forEach((source) => {\n if (!source.dataset.src) {\n return;\n }\n source.src = source.dataset.src;\n });\n\n return new Promise<void>((resolve) => {\n const loadHandler = () => {\n video.removeEventListener('loadeddata', loadHandler);\n this.$log('fresh sources loaded');\n resolve();\n };\n video.addEventListener('loadeddata', loadHandler);\n video.load();\n });\n }\n\n /**\n * Load\n * @returns {Promise}\n */\n load(): Promise<any[]> {\n return Promise.all([this.loadPoster(), this.loadSources()]);\n }\n\n /**\n * Load on mount.\n */\n async mounted() {\n this.$log('mounted');\n const { video } = this.$refs;\n\n if (!video) {\n throw new Error('[VideoFigure] The `video` ref is required.');\n }\n\n if (!(video instanceof HTMLVideoElement)) {\n throw new Error('[VideoFigure] The `video` ref must be an `<video>` element.');\n }\n\n if (!this.$options.lazy) {\n this.$log('Lazy loading disabled');\n return;\n }\n\n this.$log('start loading');\n await this.load();\n this.$log('all is loaded');\n await this.enter();\n this.$log('transition done');\n this.$emit('load');\n }\n\n /**\n * Terminate the component on load.\n */\n onLoad() {\n this.$terminate();\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,2BAA2B;AAEpC,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAcnB,MAAM,oBAAqD;AAAA,EAChE;AAAA,EACA;AAAA,IACE,WAAW,CAAC,GAAG,CAAC;AAAA,EAClB;AACF,EAAwB;AAAA;AAAA;AAAA;AAAA,EAItB,OAAO,SAAqB;AAAA,IAC1B,GAAG,WAAW;AAAA,IACd,MAAM;AAAA,IACN,OAAO,CAAC,MAAM;AAAA,IACd,MAAM,CAAC,OAAO;AAAA,IACd,SAAS;AAAA,MACP,GAAG,WAAW,OAAO;AAAA,MACrB,MAAM;AAAA,IACR;AAAA,EACF;AAAA;AAA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;AAEA,QAAI,EAAE,iBAAiB,mBAAmB;AACxC,YAAM,IAAI,MAAM,6DAA6D;AAAA,IAC/E;AAEA,QAAI,CAAC,KAAK,SAAS,MAAM;AACvB,WAAK,KAAK,uBAAuB;AACjC;AAAA,IACF;AAEA,SAAK,KAAK,eAAe;AACzB,UAAM,KAAK,KAAK;AAChB,SAAK,KAAK,eAAe;AACzB,UAAM,KAAK,MAAM;AACjB,SAAK,KAAK,iBAAiB;AAC3B,SAAK,MAAM,MAAM;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA,EAKA,SAAS;AACP,SAAK,WAAW;AAAA,EAClB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
withoutLeadingSlash,
|
|
4
4
|
withoutTrailingSlash
|
|
5
5
|
} from "@studiometa/js-toolkit/utils";
|
|
6
|
-
import { loadImage } from "../
|
|
6
|
+
import { loadImage } from "../Figure/utils.js";
|
|
7
7
|
import { FigureVideo } from "./FigureVideo.js";
|
|
8
8
|
function normalizeSize(that, prop) {
|
|
9
9
|
const { step } = that.$options;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/ui/atoms/FigureVideo/FigureVideoTwicpics.ts"],
|
|
4
|
-
"sourcesContent": ["import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport {\n withLeadingSlash,\n withoutLeadingSlash,\n withoutTrailingSlash,\n} from '@studiometa/js-toolkit/utils';\nimport { loadImage } from '../
|
|
4
|
+
"sourcesContent": ["import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport {\n withLeadingSlash,\n withoutLeadingSlash,\n withoutTrailingSlash,\n} from '@studiometa/js-toolkit/utils';\nimport { loadImage } from '../Figure/utils.js';\nimport { FigureVideo } from './FigureVideo.js';\n\nexport interface FigureVideoTwicpicsProps extends BaseProps {\n $refs: {\n video: HTMLVideoElement;\n };\n $options: {\n lazy: boolean;\n transform: string;\n domain: string;\n path: string;\n step: number;\n mode: string;\n };\n}\n\n/**\n * Normalize the given size to the step option.\n */\n// eslint-disable-next-line no-use-before-define\nfunction normalizeSize(that: FigureVideoTwicpics, prop: string): number {\n const { step } = that.$options;\n return Math.ceil(that.$refs.video[prop] / step) * step;\n}\n\n/**\n * FigureVideo class.\n *\n * Manager lazyloading image sources.\n */\nexport class FigureVideoTwicpics<T extends BaseProps = BaseProps> extends FigureVideo<\n T & FigureVideoTwicpicsProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...FigureVideo.config,\n name: 'FigureVideoTwicpics',\n options: {\n ...FigureVideo.config.options,\n transform: String,\n domain: String,\n path: String,\n step: {\n type: Number,\n default: 50,\n },\n mode: {\n type: String,\n default: 'cover',\n },\n },\n };\n\n /**\n * Get the Twicpics path.\n */\n get path(): string {\n return withoutTrailingSlash(withoutLeadingSlash(this.$options.path));\n }\n\n /**\n * Get the Twicpics domain.\n */\n get domain(): string {\n if (this.$options.domain) {\n return this.$options.domain;\n }\n const url = new URL(this.sources[0].dataset.src);\n return url.host;\n }\n\n /**\n * Format the source for Twicpics.\n * @param {string} src\n * @param {Array} options\n * @returns {string}\n */\n formatSrc(src: string, options: Array<string> = []): string {\n const url = new URL(src, 'https://localhost');\n url.host = this.domain;\n url.port = '';\n\n if (this.path && !url.pathname.startsWith(withLeadingSlash(this.path))) {\n url.pathname = `/${this.path}${url.pathname}`;\n }\n\n const width = normalizeSize(this, 'offsetWidth');\n const height = normalizeSize(this, 'offsetHeight');\n\n this.$log(this.$options.mode, width, height);\n\n url.searchParams.set(\n 'twic',\n ['v1', this.$options.transform, `${this.$options.mode}=${width}x${height}`, ...options]\n .filter(Boolean)\n .join('/'),\n );\n\n url.search = decodeURIComponent(url.search);\n\n return url.toString();\n }\n\n /**\n * Load poster\n */\n loadPoster(): Promise<void|HTMLImageElement> {\n const { video } = this.$refs;\n\n if (!video.dataset.poster) {\n return Promise.resolve();\n }\n\n const twicPoster = this.formatSrc(video.dataset.poster);\n\n return loadImage(twicPoster).then(() => {\n video.poster = twicPoster;\n this.$log('fresh poster loaded');\n });\n }\n\n /**\n * Load sources\n */\n loadSources(): Promise<void> {\n const { video } = this.$refs;\n\n this.sources.forEach((source) => {\n if (!source.dataset.src) {\n return;\n }\n source.src = this.formatSrc(\n source.dataset.src,\n source.dataset.output ? [`output=${source.dataset.output}`] : [],\n );\n });\n\n return new Promise((resolve) => {\n const loadHandler = () => {\n resolve();\n video.removeEventListener('canplaythrough', loadHandler);\n this.$log('fresh sources loaded');\n };\n\n video.addEventListener('canplaythrough', loadHandler);\n\n this.$refs.video.width = normalizeSize(this, 'offsetWidth');\n this.$refs.video.height = normalizeSize(this, 'offsetHeight');\n\n video.load();\n });\n }\n\n /**\n * Reassign the source from the original on resize.\n */\n async resized() {\n const width = normalizeSize(this, 'offsetWidth');\n const height = normalizeSize(this, 'offsetHeight');\n\n if (width === this.$refs.video.width && height === this.$refs.video.height) {\n return;\n }\n\n this.$refs.video.width = width;\n this.$refs.video.height = height;\n\n await this.load();\n }\n\n /**\n * Do not terminate on image load as we need to set the src on resize.\n */\n onLoad() {\n // Do not terminate on image load as we need.\n }\n}\n"],
|
|
5
5
|
"mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAoB5B,SAAS,cAAc,MAA2B,MAAsB;AACtE,QAAM,EAAE,KAAK,IAAI,KAAK;AACtB,SAAO,KAAK,KAAK,KAAK,MAAM,MAAM,IAAI,IAAI,IAAI,IAAI;AACpD;AAOO,MAAM,4BAA6D,YAExE;AAAA;AAAA;AAAA;AAAA,EAIA,OAAO,SAAqB;AAAA,IAC1B,GAAG,YAAY;AAAA,IACf,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG,YAAY,OAAO;AAAA,MACtB,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,MAAM;AAAA,MACN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SAAS;AAAA,EAET;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseConfig } from '@studiometa/js-toolkit';
|
|
2
|
-
declare const ScrollAnimationChildWithEase_base: import("@studiometa/js-toolkit").BaseDecorator<import("./animationScrollWithEase.js").AnimationScrollWithEaseInterface, import("#private").AbstractScrollAnimation<import("@studiometa/js-toolkit").BaseProps>, import("./animationScrollWithEase.js").AnimationScrollWithEaseProps>;
|
|
2
|
+
declare const ScrollAnimationChildWithEase_base: import("@studiometa/js-toolkit").BaseDecorator<import("./animationScrollWithEase.js").AnimationScrollWithEaseInterface, import("#private/index.js").AbstractScrollAnimation<import("@studiometa/js-toolkit").BaseProps>, import("./animationScrollWithEase.js").AnimationScrollWithEaseProps>;
|
|
3
3
|
/**
|
|
4
4
|
* ScrollAnimationChild class.
|
|
5
5
|
*/
|