@postnord/pn-marketweb-components 2.4.0 → 2.4.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/cjs/index-4199ff85.js +8 -4
- package/cjs/loader.cjs.js +1 -1
- package/cjs/pn-market-web-components.cjs.js +1 -1
- package/cjs/pn-play-on-scroll.cjs.entry.js +71 -0
- package/cjs/pn-scroll_2.cjs.entry.js +142 -0
- package/collection/collection-manifest.json +2 -0
- package/collection/components/animation/pn-play-on-scroll/pn-play-on-scroll.css +21 -0
- package/collection/components/animation/pn-play-on-scroll/pn-play-on-scroll.js +100 -0
- package/collection/components/animation/pn-play-on-scroll/pn-play-on-scroll.stories.js +102 -0
- package/collection/components/animation/pn-play-on-scroll/pn-video-overlay/pn-video-overlay.css +28 -0
- package/collection/components/animation/pn-play-on-scroll/pn-video-overlay/pn-video-overlay.js +116 -0
- package/collection/components/animation/pn-play-on-scroll/pn-video-overlay/translations.js +29 -0
- package/collection/components/animation/pn-scroll/pn-scroll.js +82 -37
- package/components/index.d.ts +2 -0
- package/components/index.js +2 -0
- package/components/pn-play-on-scroll.d.ts +11 -0
- package/components/pn-play-on-scroll.js +102 -0
- package/components/pn-scroll.js +1 -74
- package/components/pn-scroll2.js +87 -0
- package/components/pn-video-overlay.d.ts +11 -0
- package/components/pn-video-overlay.js +6 -0
- package/components/pn-video-overlay2.js +95 -0
- package/esm/index-c118284d.js +8 -4
- package/esm/loader.js +1 -1
- package/esm/pn-market-web-components.js +1 -1
- package/esm/pn-play-on-scroll.entry.js +67 -0
- package/esm/pn-scroll_2.entry.js +137 -0
- package/esm-es5/index-c118284d.js +1 -1
- package/esm-es5/loader.js +1 -1
- package/esm-es5/pn-market-web-components.js +1 -1
- package/esm-es5/pn-play-on-scroll.entry.js +1 -0
- package/esm-es5/pn-scroll_2.entry.js +1 -0
- package/package.json +1 -1
- package/pn-market-web-components/p-1590ae58.system.entry.js +1 -0
- package/pn-market-web-components/p-6525a912.entry.js +1 -0
- package/pn-market-web-components/p-b1935780.entry.js +1 -0
- package/pn-market-web-components/p-d295ef71.system.js +1 -1
- package/pn-market-web-components/p-e80d820e.system.entry.js +1 -0
- package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
- package/types/components/animation/pn-play-on-scroll/pn-play-on-scroll.d.ts +15 -0
- package/types/components/animation/pn-play-on-scroll/pn-video-overlay/pn-video-overlay.d.ts +15 -0
- package/types/components/animation/pn-play-on-scroll/pn-video-overlay/translations.d.ts +29 -0
- package/types/components/animation/pn-scroll/pn-scroll.d.ts +4 -1
- package/types/components/widgets/pn-proxio-pricegroup/pn-proxio-pricegroup.d.ts +1 -1
- package/types/components.d.ts +43 -2
- package/cjs/pn-scroll.cjs.entry.js +0 -59
- package/esm/pn-scroll.entry.js +0 -55
- package/esm-es5/pn-scroll.entry.js +0 -1
- package/pn-market-web-components/p-12f461db.entry.js +0 -1
- package/pn-market-web-components/p-bab17118.system.entry.js +0 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import readme from './readme.md';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Scroller/Fade',
|
|
5
|
+
parameters: {
|
|
6
|
+
notes: readme,
|
|
7
|
+
layout: 'fullscreen',
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const PlayOnScrollTemplate = args => {
|
|
12
|
+
return `
|
|
13
|
+
<br>
|
|
14
|
+
<br>
|
|
15
|
+
<br>
|
|
16
|
+
<br>
|
|
17
|
+
<br>
|
|
18
|
+
<br>
|
|
19
|
+
<br>
|
|
20
|
+
<br>
|
|
21
|
+
<br>
|
|
22
|
+
<br>
|
|
23
|
+
<br>
|
|
24
|
+
<br>
|
|
25
|
+
<br>
|
|
26
|
+
<br>
|
|
27
|
+
<br>
|
|
28
|
+
<br>
|
|
29
|
+
<br>
|
|
30
|
+
<br>
|
|
31
|
+
<br>
|
|
32
|
+
<br>
|
|
33
|
+
<br>
|
|
34
|
+
<br>
|
|
35
|
+
<br>
|
|
36
|
+
<br>
|
|
37
|
+
<br>
|
|
38
|
+
<br>
|
|
39
|
+
<br>
|
|
40
|
+
<br>
|
|
41
|
+
<br>
|
|
42
|
+
<br>
|
|
43
|
+
<br>
|
|
44
|
+
<br>
|
|
45
|
+
<br>
|
|
46
|
+
<br>
|
|
47
|
+
<br>
|
|
48
|
+
<br>
|
|
49
|
+
<br>
|
|
50
|
+
<br>
|
|
51
|
+
<br>
|
|
52
|
+
<br>
|
|
53
|
+
<br>
|
|
54
|
+
<br>
|
|
55
|
+
<br>
|
|
56
|
+
<br>
|
|
57
|
+
<br>
|
|
58
|
+
<br>
|
|
59
|
+
<br>
|
|
60
|
+
<br>
|
|
61
|
+
<br>
|
|
62
|
+
<br>
|
|
63
|
+
<br>
|
|
64
|
+
<br>
|
|
65
|
+
<br>
|
|
66
|
+
<br>
|
|
67
|
+
<br>
|
|
68
|
+
<br>
|
|
69
|
+
<br>
|
|
70
|
+
<br>
|
|
71
|
+
<br>
|
|
72
|
+
<br>
|
|
73
|
+
<br>
|
|
74
|
+
<br>
|
|
75
|
+
<br>
|
|
76
|
+
<br>
|
|
77
|
+
<br>
|
|
78
|
+
<br>
|
|
79
|
+
<br>
|
|
80
|
+
<br>
|
|
81
|
+
<br>
|
|
82
|
+
<br>
|
|
83
|
+
<br>
|
|
84
|
+
<pn-play-on-scroll></pn-play-on-scroll>
|
|
85
|
+
<br>
|
|
86
|
+
<br>
|
|
87
|
+
<br>
|
|
88
|
+
<br>
|
|
89
|
+
<br>
|
|
90
|
+
<br>
|
|
91
|
+
<br>
|
|
92
|
+
<br>
|
|
93
|
+
<br>
|
|
94
|
+
<br>
|
|
95
|
+
<br>
|
|
96
|
+
<br>
|
|
97
|
+
<br>
|
|
98
|
+
`;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const PlayOnScroll = PlayOnScrollTemplate.bind({});
|
|
102
|
+
PlayOnScroll.args = {};
|
package/collection/components/animation/pn-play-on-scroll/pn-video-overlay/pn-video-overlay.css
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
pn-video-overlay button {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
border-radius: 50%;
|
|
6
|
+
padding: 0;
|
|
7
|
+
border: none;
|
|
8
|
+
outline: none;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
background-color: transparent;
|
|
11
|
+
}
|
|
12
|
+
pn-video-overlay button:hover svg rect {
|
|
13
|
+
fill: #003d5f;
|
|
14
|
+
}
|
|
15
|
+
pn-video-overlay button:active svg rect {
|
|
16
|
+
fill: #001c2c;
|
|
17
|
+
}
|
|
18
|
+
pn-video-overlay button:focus, pn-video-overlay button:focus-visible {
|
|
19
|
+
outline: 2px solid #FFFFFF;
|
|
20
|
+
}
|
|
21
|
+
pn-video-overlay button svg {
|
|
22
|
+
scale: 0.7;
|
|
23
|
+
}
|
|
24
|
+
@media screen and (min-width: 768px) {
|
|
25
|
+
pn-video-overlay button svg {
|
|
26
|
+
scale: 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
package/collection/components/animation/pn-play-on-scroll/pn-video-overlay/pn-video-overlay.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { h, Host } from '@stencil/core';
|
|
2
|
+
import { translations } from './translations';
|
|
3
|
+
export class PnVideoOverlay {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.handlePlayPauseClicked = () => {
|
|
6
|
+
this.playPauseClicked.emit();
|
|
7
|
+
};
|
|
8
|
+
this.renderPlayIcon = () => {
|
|
9
|
+
return (h("svg", { width: "64", height: "64", viewBox: "0 0 64 64", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("rect", { width: "64", height: "64", rx: "32", fill: "#005D92" }), h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M52.7123 32C52.7123 20.5609 43.4391 11.2877 32 11.2877C26.5827 11.2877 21.6544 13.3653 17.9624 16.7701C17.295 17.3855 16.255 17.3434 15.6396 16.6761C15.0241 16.0087 15.0662 14.9687 15.7336 14.3532C20.0088 10.4105 25.7248 8 32 8C45.2548 8 56 18.7452 56 32C56 45.2548 45.2548 56 32 56C18.7452 56 8 45.2548 8 32C8 31.0921 8.73597 30.3562 9.64383 30.3562C10.5517 30.3562 11.2877 31.0921 11.2877 32C11.2877 43.4391 20.5609 52.7123 32 52.7123C43.4391 52.7123 52.7123 43.4391 52.7123 32ZM24.5757 20.0718C25.069 19.7743 25.682 19.7567 26.1916 20.0255L44.6025 29.7368C45.1246 30.0122 45.459 30.5463 45.4785 31.1363C45.4981 31.7262 45.1999 32.2814 44.6971 32.5907L26.2862 43.9205C25.779 44.2327 25.1427 44.246 24.6228 43.9555C24.1029 43.665 23.7808 43.1161 23.7808 42.5205V21.4795C23.7808 20.9034 24.0824 20.3693 24.5757 20.0718ZM27.0685 24.205V39.5788L40.5205 31.3006L27.0685 24.205ZM13.8639 20.7673C14.7717 20.7673 15.5077 20.0314 15.5077 19.1235C15.5077 18.2156 14.7717 17.4797 13.8639 17.4797C12.956 17.4797 12.22 18.2156 12.22 19.1235C12.22 20.0314 12.956 20.7673 13.8639 20.7673Z", fill: "white" })));
|
|
10
|
+
};
|
|
11
|
+
this.renderPauseIcon = () => {
|
|
12
|
+
return (h("svg", { width: "64", height: "64", viewBox: "0 0 64 64", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("rect", { width: "64", height: "64", rx: "32", fill: "#005D92" }), h("g", { "clip-path": "url(#clip0_3459_35103)" }, h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M52.8352 32C52.8352 20.6593 43.6044 11.1648 32 11.1648C26.7253 11.1648 21.7143 13.2747 18.022 16.7033C17.2308 17.2308 16.4396 17.2308 15.6484 16.7033C14.8571 16.1758 15.1209 15.1209 15.6484 14.3297C20.1319 10.3736 25.6703 8 32 8C45.1868 8 56 18.8132 56 32C56 45.1868 45.1868 56 32 56C18.8132 56 8 45.4505 8 32C8 31.2088 8.79121 30.4176 9.58242 30.4176C10.3736 30.4176 11.1648 31.2088 11.1648 32C11.1648 43.3407 20.3956 52.8352 32 52.8352C43.6044 52.8352 52.8352 43.6044 52.8352 32ZM13.8022 20.9231C14.5934 20.9231 15.3846 20.1319 15.3846 19.3407C15.3846 18.5495 14.8571 17.4945 13.8022 17.4945C12.7473 17.4945 12.2198 18.2857 12.2198 19.0769C12.2198 19.8681 13.011 20.9231 13.8022 20.9231Z", fill: "white" }), h("path", { d: "M37.3571 20C36.391 20 35.4644 20.3793 34.7813 21.0544C34.0981 21.7295 33.7143 22.6452 33.7143 23.6V40.4C33.7143 41.3548 34.0981 42.2705 34.7813 42.9456C35.4644 43.6207 36.391 44 37.3571 44C38.3233 44 39.2499 43.6207 39.933 42.9456C40.6162 42.2705 41 41.3548 41 40.4V23.6C41 22.6452 40.6162 21.7295 39.933 21.0544C39.2499 20.3793 38.3233 20 37.3571 20ZM38.5714 40.4C38.5714 40.7182 38.4434 41.0234 38.2157 41.2484C37.988 41.4734 37.6792 41.5998 37.3571 41.5998C37.0351 41.5998 36.7263 41.4734 36.4986 41.2484C36.2709 41.0234 36.1429 40.7182 36.1429 40.4V23.6C36.1429 23.2818 36.2709 22.9766 36.4986 22.7516C36.7263 22.5266 37.0351 22.4002 37.3571 22.4002C37.6792 22.4002 37.988 22.5266 38.2157 22.7516C38.4434 22.9766 38.5714 23.2818 38.5714 23.6V40.4ZM27.6429 20C26.6767 20 25.7501 20.3793 25.067 21.0544C24.3838 21.7295 24 22.6452 24 23.6V40.4C24 41.3548 24.3838 42.2705 25.067 42.9456C25.7501 43.6207 26.6767 44 27.6429 44C28.609 44 29.5356 43.6207 30.2187 42.9456C30.9019 42.2705 31.2857 41.3548 31.2857 40.4V23.6C31.2857 22.6452 30.9019 21.7295 30.2187 21.0544C29.5356 20.3793 28.609 20 27.6429 20ZM28.8571 40.4C28.8571 40.7182 28.7291 41.0234 28.5014 41.2484C28.2737 41.4734 27.9649 41.5998 27.6429 41.5998C27.3208 41.5998 27.012 41.4734 26.7843 41.2484C26.5566 41.0234 26.4286 40.7182 26.4286 40.4V23.6C26.4286 23.2818 26.5566 22.9766 26.7843 22.7516C27.012 22.5266 27.3208 22.4002 27.6429 22.4002C27.9649 22.4002 28.2737 22.5266 28.5014 22.7516C28.7291 22.9766 28.8571 23.2818 28.8571 23.6V40.4Z", fill: "white" })), h("defs", null, h("clipPath", { id: "clip0_3459_35103" }, h("rect", { width: "48", height: "48", fill: "white", transform: "translate(8 8)" })))));
|
|
13
|
+
};
|
|
14
|
+
this.language = 'en';
|
|
15
|
+
this.isPaused = false;
|
|
16
|
+
this.i18n = undefined;
|
|
17
|
+
}
|
|
18
|
+
componentWillLoad() {
|
|
19
|
+
this.setTranslations();
|
|
20
|
+
}
|
|
21
|
+
setTranslations() {
|
|
22
|
+
if (this.language === 'nb') {
|
|
23
|
+
this.language = 'no';
|
|
24
|
+
}
|
|
25
|
+
if (this.language && translations[this.language]) {
|
|
26
|
+
this.i18n = translations[this.language];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
onLanguageChange() {
|
|
30
|
+
this.setTranslations();
|
|
31
|
+
}
|
|
32
|
+
render() {
|
|
33
|
+
return (h(Host, null, h("button", { "aria-label": `${this.i18n.ariaLabel}`, onClick: this.handlePlayPauseClicked }, this.isPaused ? this.renderPlayIcon() : this.renderPauseIcon())));
|
|
34
|
+
}
|
|
35
|
+
static get is() { return "pn-video-overlay"; }
|
|
36
|
+
static get originalStyleUrls() {
|
|
37
|
+
return {
|
|
38
|
+
"$": ["pn-video-overlay.scss"]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
static get styleUrls() {
|
|
42
|
+
return {
|
|
43
|
+
"$": ["pn-video-overlay.css"]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
static get properties() {
|
|
47
|
+
return {
|
|
48
|
+
"language": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"mutable": false,
|
|
51
|
+
"complexType": {
|
|
52
|
+
"original": "string",
|
|
53
|
+
"resolved": "string",
|
|
54
|
+
"references": {}
|
|
55
|
+
},
|
|
56
|
+
"required": false,
|
|
57
|
+
"optional": false,
|
|
58
|
+
"docs": {
|
|
59
|
+
"tags": [],
|
|
60
|
+
"text": ""
|
|
61
|
+
},
|
|
62
|
+
"attribute": "language",
|
|
63
|
+
"reflect": false,
|
|
64
|
+
"defaultValue": "'en'"
|
|
65
|
+
},
|
|
66
|
+
"isPaused": {
|
|
67
|
+
"type": "boolean",
|
|
68
|
+
"mutable": false,
|
|
69
|
+
"complexType": {
|
|
70
|
+
"original": "boolean",
|
|
71
|
+
"resolved": "boolean",
|
|
72
|
+
"references": {}
|
|
73
|
+
},
|
|
74
|
+
"required": false,
|
|
75
|
+
"optional": false,
|
|
76
|
+
"docs": {
|
|
77
|
+
"tags": [],
|
|
78
|
+
"text": ""
|
|
79
|
+
},
|
|
80
|
+
"attribute": "is-paused",
|
|
81
|
+
"reflect": false,
|
|
82
|
+
"defaultValue": "false"
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
static get states() {
|
|
87
|
+
return {
|
|
88
|
+
"i18n": {}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
static get events() {
|
|
92
|
+
return [{
|
|
93
|
+
"method": "playPauseClicked",
|
|
94
|
+
"name": "playPauseClicked",
|
|
95
|
+
"bubbles": true,
|
|
96
|
+
"cancelable": true,
|
|
97
|
+
"composed": true,
|
|
98
|
+
"docs": {
|
|
99
|
+
"tags": [],
|
|
100
|
+
"text": ""
|
|
101
|
+
},
|
|
102
|
+
"complexType": {
|
|
103
|
+
"original": "void",
|
|
104
|
+
"resolved": "void",
|
|
105
|
+
"references": {}
|
|
106
|
+
}
|
|
107
|
+
}];
|
|
108
|
+
}
|
|
109
|
+
static get elementRef() { return "hostElement"; }
|
|
110
|
+
static get watchers() {
|
|
111
|
+
return [{
|
|
112
|
+
"propName": "language",
|
|
113
|
+
"methodName": "onLanguageChange"
|
|
114
|
+
}];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const translations = {
|
|
2
|
+
sv: {
|
|
3
|
+
ariaLabel: 'Spela eller pausa video',
|
|
4
|
+
},
|
|
5
|
+
en: {
|
|
6
|
+
ariaLabel: 'Play or pause video',
|
|
7
|
+
},
|
|
8
|
+
da: {
|
|
9
|
+
ariaLabel: 'Afspil eller sæt video på pause',
|
|
10
|
+
},
|
|
11
|
+
no: {
|
|
12
|
+
ariaLabel: 'Spill av eller sett video på pause',
|
|
13
|
+
},
|
|
14
|
+
fi: {
|
|
15
|
+
ariaLabel: 'Toista tai keskeytä video',
|
|
16
|
+
},
|
|
17
|
+
de: {
|
|
18
|
+
ariaLabel: 'Video abspielen oder anhalten',
|
|
19
|
+
},
|
|
20
|
+
zh: {
|
|
21
|
+
sharelabel: 'Play or pause video',
|
|
22
|
+
},
|
|
23
|
+
it: {
|
|
24
|
+
sharelabel: 'Play or pause video',
|
|
25
|
+
},
|
|
26
|
+
nl: {
|
|
27
|
+
sharelabel: 'Play or pause video',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { h, Host } from '@stencil/core';
|
|
3
|
-
const defaultIntersectionCallback = (entries, observer, shouldLoop = false) => {
|
|
4
|
-
entries.forEach(entry => {
|
|
5
|
-
if (!shouldLoop) {
|
|
6
|
-
if (entry.isIntersecting) {
|
|
7
|
-
entry.target.classList.add('in-view');
|
|
8
|
-
//stop observering after added
|
|
9
|
-
observer.unobserve(entry.target);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
//toggle and keep observing and toggling, for continous behavior on element
|
|
14
|
-
entry.target.classList.toggle('in-view', entry.isIntersecting);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
3
|
const defaultObserverOptions = {
|
|
19
4
|
root: null,
|
|
20
5
|
threshold: 0,
|
|
@@ -23,21 +8,45 @@ const defaultObserverOptions = {
|
|
|
23
8
|
const SCROLL_ID = `pn-scroll-wrapper-id-`;
|
|
24
9
|
export class PnScroll {
|
|
25
10
|
constructor() {
|
|
26
|
-
this.intersectionCustomCallback = defaultIntersectionCallback;
|
|
27
11
|
this.observerOptions = defaultObserverOptions;
|
|
28
12
|
this.behaviourClasses = 'fade slide-up';
|
|
29
13
|
this.transitionDurationSeconds = 0.5;
|
|
14
|
+
this.shouldLoop = false;
|
|
15
|
+
this.intersectFunc = undefined;
|
|
16
|
+
this.notIntersectFunc = undefined;
|
|
30
17
|
this.compId = null;
|
|
31
18
|
}
|
|
32
19
|
generateUniqueId() {
|
|
33
20
|
return uuidv4();
|
|
34
21
|
}
|
|
22
|
+
handleIntersection(entries, observer, onIntersecting, onNotIntersecting, shouldLoop) {
|
|
23
|
+
entries.forEach(entry => {
|
|
24
|
+
if (!shouldLoop) {
|
|
25
|
+
if (!entry.isIntersecting) {
|
|
26
|
+
onNotIntersecting === null || onNotIntersecting === void 0 ? void 0 : onNotIntersecting(entry, observer);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
entry.target.classList.add('in-view');
|
|
30
|
+
onIntersecting === null || onIntersecting === void 0 ? void 0 : onIntersecting(entry, observer);
|
|
31
|
+
observer.unobserve(entry.target);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
entry.target.classList.toggle('in-view', entry.isIntersecting);
|
|
35
|
+
if (entry.isIntersecting) {
|
|
36
|
+
onIntersecting === null || onIntersecting === void 0 ? void 0 : onIntersecting(entry, observer);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
onNotIntersecting === null || onNotIntersecting === void 0 ? void 0 : onNotIntersecting(entry, observer);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
35
44
|
//on load, generate unique id for this wrapper
|
|
36
45
|
componentWillLoad() {
|
|
37
46
|
this.compId = this.generateUniqueId();
|
|
38
47
|
}
|
|
39
48
|
componentDidLoad() {
|
|
40
|
-
const observer = new IntersectionObserver(this.
|
|
49
|
+
const observer = new IntersectionObserver((entries, observer) => this.handleIntersection(entries, observer, this.intersectFunc, this.notIntersectFunc, this.shouldLoop), this.observerOptions);
|
|
41
50
|
const objectToObserve = document.getElementById(`${SCROLL_ID}${this.compId}`);
|
|
42
51
|
observer.observe(objectToObserve);
|
|
43
52
|
}
|
|
@@ -57,26 +66,6 @@ export class PnScroll {
|
|
|
57
66
|
}
|
|
58
67
|
static get properties() {
|
|
59
68
|
return {
|
|
60
|
-
"intersectionCustomCallback": {
|
|
61
|
-
"type": "unknown",
|
|
62
|
-
"mutable": false,
|
|
63
|
-
"complexType": {
|
|
64
|
-
"original": "IntersectionObserverCallback",
|
|
65
|
-
"resolved": "IntersectionObserverCallback",
|
|
66
|
-
"references": {
|
|
67
|
-
"IntersectionObserverCallback": {
|
|
68
|
-
"location": "global"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
"required": false,
|
|
73
|
-
"optional": false,
|
|
74
|
-
"docs": {
|
|
75
|
-
"tags": [],
|
|
76
|
-
"text": ""
|
|
77
|
-
},
|
|
78
|
-
"defaultValue": "defaultIntersectionCallback"
|
|
79
|
-
},
|
|
80
69
|
"observerOptions": {
|
|
81
70
|
"type": "unknown",
|
|
82
71
|
"mutable": false,
|
|
@@ -132,6 +121,62 @@ export class PnScroll {
|
|
|
132
121
|
"attribute": "transition-duration-seconds",
|
|
133
122
|
"reflect": false,
|
|
134
123
|
"defaultValue": "0.5"
|
|
124
|
+
},
|
|
125
|
+
"shouldLoop": {
|
|
126
|
+
"type": "boolean",
|
|
127
|
+
"mutable": false,
|
|
128
|
+
"complexType": {
|
|
129
|
+
"original": "boolean",
|
|
130
|
+
"resolved": "boolean",
|
|
131
|
+
"references": {}
|
|
132
|
+
},
|
|
133
|
+
"required": false,
|
|
134
|
+
"optional": true,
|
|
135
|
+
"docs": {
|
|
136
|
+
"tags": [],
|
|
137
|
+
"text": ""
|
|
138
|
+
},
|
|
139
|
+
"attribute": "should-loop",
|
|
140
|
+
"reflect": false,
|
|
141
|
+
"defaultValue": "false"
|
|
142
|
+
},
|
|
143
|
+
"intersectFunc": {
|
|
144
|
+
"type": "unknown",
|
|
145
|
+
"mutable": false,
|
|
146
|
+
"complexType": {
|
|
147
|
+
"original": "Function",
|
|
148
|
+
"resolved": "Function",
|
|
149
|
+
"references": {
|
|
150
|
+
"Function": {
|
|
151
|
+
"location": "global"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"required": false,
|
|
156
|
+
"optional": true,
|
|
157
|
+
"docs": {
|
|
158
|
+
"tags": [],
|
|
159
|
+
"text": ""
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"notIntersectFunc": {
|
|
163
|
+
"type": "unknown",
|
|
164
|
+
"mutable": false,
|
|
165
|
+
"complexType": {
|
|
166
|
+
"original": "Function",
|
|
167
|
+
"resolved": "Function",
|
|
168
|
+
"references": {
|
|
169
|
+
"Function": {
|
|
170
|
+
"location": "global"
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"required": false,
|
|
175
|
+
"optional": true,
|
|
176
|
+
"docs": {
|
|
177
|
+
"tags": [],
|
|
178
|
+
"text": ""
|
|
179
|
+
}
|
|
135
180
|
}
|
|
136
181
|
};
|
|
137
182
|
}
|
package/components/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export { PnMarketwebSiteheaderUnifiedLogin as PnMarketwebSiteheaderUnifiedLogin
|
|
|
35
35
|
export { PnMultiFormField as PnMultiFormfield } from '../types/components/layout-components/pn-multi-formfield/pn-multi-formfield';
|
|
36
36
|
export { PnSpotlight as PnParcelTracker } from '../types/components/cta/pn-parcel-tracker/pn-parcel-tracker';
|
|
37
37
|
export { PnPexPricefinder as PnPexPricefinder } from '../types/components/widgets/pn-pex-pricefinder/pn-pex-pricefinder';
|
|
38
|
+
export { PnPlayOnScroll as PnPlayOnScroll } from '../types/components/animation/pn-play-on-scroll/pn-play-on-scroll';
|
|
38
39
|
export { PnProductCard as PnProductCard } from '../types/components/widgets/pn-product-card/pn-product-card';
|
|
39
40
|
export { PnProductCardInfo as PnProductCardInfo } from '../types/components/widgets/pn-product-card/pn-product-card-info';
|
|
40
41
|
export { PnProductCardPrice as PnProductCardPrice } from '../types/components/widgets/pn-product-card/pn-product-card-price';
|
|
@@ -74,6 +75,7 @@ export { PnStatsInfo as PnStatsInfo } from '../types/components/data-visualizati
|
|
|
74
75
|
export { PnStatsInfoData as PnStatsInfoData } from '../types/components/data-visualization/pn-stats-info/pn-stats-info-data/pn-stats-info-data';
|
|
75
76
|
export { PnTeaserCard as PnTeaserCard } from '../types/components/cards/pn-teaser-card/pn-teaser-card';
|
|
76
77
|
export { PnTiletag as PnTitletag } from '../types/components/minor/pn-titletag/pn-titletag';
|
|
78
|
+
export { PnVideoOverlay as PnVideoOverlay } from '../types/components/animation/pn-play-on-scroll/pn-video-overlay/pn-video-overlay';
|
|
77
79
|
|
|
78
80
|
/**
|
|
79
81
|
* Used to manually set the base path where assets can be found.
|
package/components/index.js
CHANGED
|
@@ -35,6 +35,7 @@ export { PnMarketwebSiteheaderUnifiedLogin, defineCustomElement as defineCustomE
|
|
|
35
35
|
export { PnMultiFormfield, defineCustomElement as defineCustomElementPnMultiFormfield } from './pn-multi-formfield.js';
|
|
36
36
|
export { PnParcelTracker, defineCustomElement as defineCustomElementPnParcelTracker } from './pn-parcel-tracker.js';
|
|
37
37
|
export { PnPexPricefinder, defineCustomElement as defineCustomElementPnPexPricefinder } from './pn-pex-pricefinder.js';
|
|
38
|
+
export { PnPlayOnScroll, defineCustomElement as defineCustomElementPnPlayOnScroll } from './pn-play-on-scroll.js';
|
|
38
39
|
export { PnProductCard, defineCustomElement as defineCustomElementPnProductCard } from './pn-product-card.js';
|
|
39
40
|
export { PnProductCardInfo, defineCustomElement as defineCustomElementPnProductCardInfo } from './pn-product-card-info.js';
|
|
40
41
|
export { PnProductCardPrice, defineCustomElement as defineCustomElementPnProductCardPrice } from './pn-product-card-price.js';
|
|
@@ -74,3 +75,4 @@ export { PnStatsInfo, defineCustomElement as defineCustomElementPnStatsInfo } fr
|
|
|
74
75
|
export { PnStatsInfoData, defineCustomElement as defineCustomElementPnStatsInfoData } from './pn-stats-info-data.js';
|
|
75
76
|
export { PnTeaserCard, defineCustomElement as defineCustomElementPnTeaserCard } from './pn-teaser-card.js';
|
|
76
77
|
export { PnTitletag, defineCustomElement as defineCustomElementPnTitletag } from './pn-titletag.js';
|
|
78
|
+
export { PnVideoOverlay, defineCustomElement as defineCustomElementPnVideoOverlay } from './pn-video-overlay.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface PnPlayOnScroll extends Components.PnPlayOnScroll, HTMLElement {}
|
|
4
|
+
export const PnPlayOnScroll: {
|
|
5
|
+
prototype: PnPlayOnScroll;
|
|
6
|
+
new (): PnPlayOnScroll;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { d as defineCustomElement$3 } from './pn-scroll2.js';
|
|
3
|
+
import { d as defineCustomElement$2 } from './pn-video-overlay2.js';
|
|
4
|
+
import { v as v4 } from './v4.js';
|
|
5
|
+
|
|
6
|
+
const pnPlayOnScrollCss = "pn-play-on-scroll pn-scroll [slot=scroll-affected]{position:relative;display:-ms-flexbox;display:flex}pn-play-on-scroll pn-scroll [slot=scroll-affected] video{width:100%}pn-play-on-scroll pn-scroll [slot=scroll-affected] video:hover{cursor:pointer}pn-play-on-scroll pn-scroll [slot=scroll-affected] pn-video-overlay{position:absolute;bottom:8px;left:8px}@media screen and (min-width: 768px){pn-play-on-scroll pn-scroll [slot=scroll-affected] pn-video-overlay{bottom:16px;left:16px}}";
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
play content when scoll observer sees content as inview
|
|
10
|
+
*/
|
|
11
|
+
const onIntersecting = (video, isManualPaused, togglePaused) => {
|
|
12
|
+
//what to do when intersecting, eg video.play()
|
|
13
|
+
if (!isManualPaused) {
|
|
14
|
+
video && video.play();
|
|
15
|
+
togglePaused(false);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const onNotIntersecting = (video, togglePaused) => {
|
|
19
|
+
//what to do when not intersecting, eg video.pause()
|
|
20
|
+
video && video.pause();
|
|
21
|
+
togglePaused(true);
|
|
22
|
+
};
|
|
23
|
+
const observerOptions = {
|
|
24
|
+
root: null,
|
|
25
|
+
threshold: 1,
|
|
26
|
+
rootMargin: '0px 0px 0px 0px',
|
|
27
|
+
};
|
|
28
|
+
const PnPlayOnScroll$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
this.__registerHost();
|
|
32
|
+
this.testAdditionalParamIntoCallback = true;
|
|
33
|
+
this.handlePlayPauseClicked = () => {
|
|
34
|
+
if (this.video.paused || this.video.ended) {
|
|
35
|
+
this.video.play();
|
|
36
|
+
this.isManuallyPaused = false;
|
|
37
|
+
this.isPaused = false;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.video.pause();
|
|
41
|
+
this.isManuallyPaused = true;
|
|
42
|
+
this.isPaused = true;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
this.togglePaused = (paused) => {
|
|
46
|
+
this.isPaused = paused;
|
|
47
|
+
};
|
|
48
|
+
this.videoSrc = '';
|
|
49
|
+
this.videoId = '';
|
|
50
|
+
this.isManuallyPaused = false;
|
|
51
|
+
this.isPaused = false;
|
|
52
|
+
}
|
|
53
|
+
generateUniqueId() {
|
|
54
|
+
return v4();
|
|
55
|
+
}
|
|
56
|
+
componentWillLoad() {
|
|
57
|
+
this.videoId = this.generateUniqueId();
|
|
58
|
+
}
|
|
59
|
+
componentDidLoad() {
|
|
60
|
+
this.video = document.getElementById(this.videoId);
|
|
61
|
+
this.video.addEventListener('click', this.handlePlayPauseClicked);
|
|
62
|
+
}
|
|
63
|
+
render() {
|
|
64
|
+
return (h(Host, null, h("pn-scroll", { intersectFunc: () => onIntersecting(this.video, this.isManuallyPaused, this.togglePaused), notIntersectFunc: () => onNotIntersecting(this.video, this.togglePaused), shouldLoop: true, behaviourClasses: 'some-behaviour-class', observerOptions: observerOptions }, h("div", { slot: "scroll-affected" }, h("video", { muted: true, autoPlay: true, id: `${this.videoId}` }, h("source", { src: this.videoSrc, type: "video/mp4" })), h("pn-video-overlay", { isPaused: this.isManuallyPaused || this.isPaused, onPlayPauseClicked: this.handlePlayPauseClicked })))));
|
|
65
|
+
}
|
|
66
|
+
get hostElement() { return this; }
|
|
67
|
+
static get style() { return pnPlayOnScrollCss; }
|
|
68
|
+
}, [0, "pn-play-on-scroll", {
|
|
69
|
+
"videoSrc": [1, "video-src"],
|
|
70
|
+
"videoId": [32],
|
|
71
|
+
"isManuallyPaused": [32],
|
|
72
|
+
"isPaused": [32]
|
|
73
|
+
}]);
|
|
74
|
+
function defineCustomElement$1() {
|
|
75
|
+
if (typeof customElements === "undefined") {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const components = ["pn-play-on-scroll", "pn-scroll", "pn-video-overlay"];
|
|
79
|
+
components.forEach(tagName => { switch (tagName) {
|
|
80
|
+
case "pn-play-on-scroll":
|
|
81
|
+
if (!customElements.get(tagName)) {
|
|
82
|
+
customElements.define(tagName, PnPlayOnScroll$1);
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case "pn-scroll":
|
|
86
|
+
if (!customElements.get(tagName)) {
|
|
87
|
+
defineCustomElement$3();
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
case "pn-video-overlay":
|
|
91
|
+
if (!customElements.get(tagName)) {
|
|
92
|
+
defineCustomElement$2();
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
} });
|
|
96
|
+
}
|
|
97
|
+
defineCustomElement$1();
|
|
98
|
+
|
|
99
|
+
const PnPlayOnScroll = PnPlayOnScroll$1;
|
|
100
|
+
const defineCustomElement = defineCustomElement$1;
|
|
101
|
+
|
|
102
|
+
export { PnPlayOnScroll, defineCustomElement };
|
package/components/pn-scroll.js
CHANGED
|
@@ -1,77 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { v as v4 } from './v4.js';
|
|
3
|
-
|
|
4
|
-
const pnScrollCss = "pn-scroll .scroll-wrapper{-webkit-transition:all var(--transition-duration) ease-in-out 250ms;transition:all var(--transition-duration) ease-in-out 250ms}pn-scroll .scroll-wrapper.fade{opacity:0}pn-scroll .scroll-wrapper.fade.in-view{opacity:1}pn-scroll .scroll-wrapper.slide-up{-webkit-transform:translateY(50px);transform:translateY(50px)}pn-scroll .scroll-wrapper.slide-up.in-view{-webkit-transform:translateY(0);transform:translateY(0)}";
|
|
5
|
-
|
|
6
|
-
const defaultIntersectionCallback = (entries, observer, shouldLoop = false) => {
|
|
7
|
-
entries.forEach(entry => {
|
|
8
|
-
if (!shouldLoop) {
|
|
9
|
-
if (entry.isIntersecting) {
|
|
10
|
-
entry.target.classList.add('in-view');
|
|
11
|
-
//stop observering after added
|
|
12
|
-
observer.unobserve(entry.target);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
//toggle and keep observing and toggling, for continous behavior on element
|
|
17
|
-
entry.target.classList.toggle('in-view', entry.isIntersecting);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
const defaultObserverOptions = {
|
|
22
|
-
root: null,
|
|
23
|
-
threshold: 0,
|
|
24
|
-
rootMargin: '0px 0px -150px 0px',
|
|
25
|
-
};
|
|
26
|
-
const SCROLL_ID = `pn-scroll-wrapper-id-`;
|
|
27
|
-
const PnScroll$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
28
|
-
constructor() {
|
|
29
|
-
super();
|
|
30
|
-
this.__registerHost();
|
|
31
|
-
this.intersectionCustomCallback = defaultIntersectionCallback;
|
|
32
|
-
this.observerOptions = defaultObserverOptions;
|
|
33
|
-
this.behaviourClasses = 'fade slide-up';
|
|
34
|
-
this.transitionDurationSeconds = 0.5;
|
|
35
|
-
this.compId = null;
|
|
36
|
-
}
|
|
37
|
-
generateUniqueId() {
|
|
38
|
-
return v4();
|
|
39
|
-
}
|
|
40
|
-
//on load, generate unique id for this wrapper
|
|
41
|
-
componentWillLoad() {
|
|
42
|
-
this.compId = this.generateUniqueId();
|
|
43
|
-
}
|
|
44
|
-
componentDidLoad() {
|
|
45
|
-
const observer = new IntersectionObserver(this.intersectionCustomCallback, this.observerOptions);
|
|
46
|
-
const objectToObserve = document.getElementById(`${SCROLL_ID}${this.compId}`);
|
|
47
|
-
observer.observe(objectToObserve);
|
|
48
|
-
}
|
|
49
|
-
render() {
|
|
50
|
-
return (h(Host, null, h("div", { class: `scroll-wrapper ${this.behaviourClasses}`, id: `${SCROLL_ID}${this.compId}`, style: { '--transition-duration': `${this.transitionDurationSeconds}s` } }, h("slot", { name: "scroll-affected" }))));
|
|
51
|
-
}
|
|
52
|
-
get hostElement() { return this; }
|
|
53
|
-
static get style() { return pnScrollCss; }
|
|
54
|
-
}, [4, "pn-scroll", {
|
|
55
|
-
"intersectionCustomCallback": [16],
|
|
56
|
-
"observerOptions": [16],
|
|
57
|
-
"behaviourClasses": [1, "behaviour-classes"],
|
|
58
|
-
"transitionDurationSeconds": [2, "transition-duration-seconds"],
|
|
59
|
-
"compId": [32]
|
|
60
|
-
}]);
|
|
61
|
-
function defineCustomElement$1() {
|
|
62
|
-
if (typeof customElements === "undefined") {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const components = ["pn-scroll"];
|
|
66
|
-
components.forEach(tagName => { switch (tagName) {
|
|
67
|
-
case "pn-scroll":
|
|
68
|
-
if (!customElements.get(tagName)) {
|
|
69
|
-
customElements.define(tagName, PnScroll$1);
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
} });
|
|
73
|
-
}
|
|
74
|
-
defineCustomElement$1();
|
|
1
|
+
import { P as PnScroll$1, d as defineCustomElement$1 } from './pn-scroll2.js';
|
|
75
2
|
|
|
76
3
|
const PnScroll = PnScroll$1;
|
|
77
4
|
const defineCustomElement = defineCustomElement$1;
|