@hopecloud/jetstream-player 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/iframe-pip-plugin.d.ts +8 -0
- package/dist/iframe-pip-plugin.js +42 -0
- package/dist/main.css +7 -0
- package/dist/player.d.ts +1 -0
- package/dist/player.js +7 -1
- package/package.json +6 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export class IFramePiPPlugin {
|
|
2
|
+
containerSelector;
|
|
3
|
+
iframe;
|
|
4
|
+
observer = null;
|
|
5
|
+
constructor(containerSelector, iframe) {
|
|
6
|
+
this.containerSelector = containerSelector;
|
|
7
|
+
this.iframe = iframe;
|
|
8
|
+
}
|
|
9
|
+
init() {
|
|
10
|
+
if (!this.iframe || !this.containerSelector)
|
|
11
|
+
return;
|
|
12
|
+
const parent = document.querySelector(this.containerSelector);
|
|
13
|
+
if (!parent) {
|
|
14
|
+
throw new Error('Selector of iframe not found');
|
|
15
|
+
}
|
|
16
|
+
this.observer = new IntersectionObserver((entries) => {
|
|
17
|
+
entries.forEach((entry) => {
|
|
18
|
+
if (!entry.isIntersecting) {
|
|
19
|
+
const height = parent.getBoundingClientRect().height + 'px';
|
|
20
|
+
this.iframe.classList.add('pip-active');
|
|
21
|
+
parent.style.height = `${height}px`;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.iframe.classList.remove('pip-active');
|
|
25
|
+
parent.style.removeProperty('height');
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}, {
|
|
29
|
+
root: window.document,
|
|
30
|
+
rootMargin: '0px',
|
|
31
|
+
threshold: 0,
|
|
32
|
+
});
|
|
33
|
+
console.log('Loging:', this.observer, parent);
|
|
34
|
+
this.observer.observe(this.iframe);
|
|
35
|
+
}
|
|
36
|
+
destory() {
|
|
37
|
+
if (this.observer) {
|
|
38
|
+
this.observer.disconnect();
|
|
39
|
+
this.observer = null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
package/dist/main.css
ADDED
package/dist/player.d.ts
CHANGED
package/dist/player.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { IFrameBuilder } from './iframe-builder';
|
|
2
|
+
import { IFramePiPPlugin } from './iframe-pip-plugin';
|
|
2
3
|
import { denormalizeEventData, normalizeEventData } from './utils';
|
|
3
4
|
export class JetStreamPlayer {
|
|
4
5
|
iframe = null;
|
|
5
6
|
options;
|
|
6
7
|
registeredEvents = {};
|
|
8
|
+
iFramePiP = null;
|
|
7
9
|
constructor(el, options) {
|
|
8
10
|
this.options = options;
|
|
9
11
|
const iframeBuilder = new IFrameBuilder({
|
|
@@ -13,14 +15,17 @@ export class JetStreamPlayer {
|
|
|
13
15
|
height: this.options.height,
|
|
14
16
|
});
|
|
15
17
|
this.iframe = iframeBuilder.iframe;
|
|
16
|
-
iframeBuilder.insertIframe(this.iframe);
|
|
17
18
|
if (this.iframe) {
|
|
19
|
+
iframeBuilder.insertIframe(this.iframe);
|
|
18
20
|
this.iframe.addEventListener('load', () => {
|
|
19
21
|
this.registerEvents();
|
|
20
22
|
this.subscribeToRegisteredEvents();
|
|
21
23
|
}, {
|
|
22
24
|
once: true,
|
|
23
25
|
});
|
|
26
|
+
if (typeof this.options.sticky !== 'undefined' && this.options.sticky) {
|
|
27
|
+
this.iFramePiP = new IFramePiPPlugin(el, this.iframe);
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
registerEvents() {
|
|
@@ -125,5 +130,6 @@ export class JetStreamPlayer {
|
|
|
125
130
|
dispose() {
|
|
126
131
|
window.removeEventListener('message', this.subscribeEventHandler.bind(this));
|
|
127
132
|
this.registeredEvents = {};
|
|
133
|
+
this.iFramePiP?.destory();
|
|
128
134
|
}
|
|
129
135
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hopecloud/jetstream-player",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "JetStream Embed Player API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
|
-
"
|
|
28
|
+
"clean": "rimraf dist/",
|
|
29
|
+
"copy-files": "copyfiles -u 1 src/main.css dist/",
|
|
30
|
+
"build": "npm run clean && tsc && npm run copy-files",
|
|
29
31
|
"pack": "npm run build && npm pack",
|
|
30
32
|
"docs:dev": "vitepress dev docs",
|
|
31
33
|
"docs:build": "vitepress build docs",
|
|
@@ -37,9 +39,11 @@
|
|
|
37
39
|
"devDependencies": {
|
|
38
40
|
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
39
41
|
"@typescript-eslint/parser": "^7.2.0",
|
|
42
|
+
"copyfiles": "^2.4.1",
|
|
40
43
|
"eslint": "^8.57.0",
|
|
41
44
|
"eslint-config-prettier": "^9.1.0",
|
|
42
45
|
"prettier": "3.2.5",
|
|
46
|
+
"rimraf": "^5.0.5",
|
|
43
47
|
"typescript": "^5.4.2",
|
|
44
48
|
"vitepress": "1.0.0-rc.45"
|
|
45
49
|
}
|