@splash-tech/jackpot-sdk 3.0.8 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,7 @@ export class FooterWidget extends FooterWidgetBase {
34
34
  });
35
35
  }
36
36
  handleChildMessage(type) {
37
+ var _a;
37
38
  switch (type) {
38
39
  case IncomingEvent.footerWidgetLoaded:
39
40
  this.sendInitialData();
@@ -44,10 +45,12 @@ export class FooterWidget extends FooterWidgetBase {
44
45
  case IncomingEvent.participateChange:
45
46
  this.emit('participateChange');
46
47
  return true;
47
- case IncomingEvent.showPopup:
48
+ case IncomingEvent.showPopup: {
49
+ const iframeRect = (_a = this.iframe) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
48
50
  this.emit('showPopup');
49
- this.expandIframe();
51
+ this.expandIframe(iframeRect);
50
52
  return true;
53
+ }
51
54
  case IncomingEvent.hidePopup:
52
55
  this.emit('hidePopup');
53
56
  this.collapseIframe();
@@ -31,6 +31,7 @@ export class FooterWidget extends FooterWidgetBase {
31
31
  });
32
32
  }
33
33
  handleChildMessage(type) {
34
+ var _a;
34
35
  switch (type) {
35
36
  case IncomingEvent.footerWidgetLoaded:
36
37
  this.sendInitialData();
@@ -38,10 +39,12 @@ export class FooterWidget extends FooterWidgetBase {
38
39
  case IncomingEvent.ready:
39
40
  this.onChildAppLoaded();
40
41
  return true;
41
- case IncomingEvent.showPopup:
42
+ case IncomingEvent.showPopup: {
43
+ const iframeRect = (_a = this.iframe) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
42
44
  this.emit('showPopup');
43
- this.expandIframe();
45
+ this.expandIframe(iframeRect);
44
46
  return true;
47
+ }
45
48
  case IncomingEvent.hidePopup:
46
49
  this.emit('hidePopup');
47
50
  this.collapseIframe();
@@ -15,7 +15,7 @@ export declare abstract class FooterWidgetBase<TConfig extends FooterWidgetBaseC
15
15
  updateData(partialData: object): void;
16
16
  destroy(): void;
17
17
  protected styleIframe(iframe: HTMLIFrameElement): HTMLIFrameElement;
18
- protected expandIframe(): void;
18
+ protected expandIframe(iframeRect?: DOMRect): void;
19
19
  protected collapseIframe(): void;
20
20
  private setIframeHeight;
21
21
  protected onChildAppLoaded(): void;
@@ -57,6 +57,7 @@ export class FooterWidgetBase extends BaseWidget {
57
57
  }
58
58
  styleIframe(iframe) {
59
59
  iframe.style.left = '0';
60
+ iframe.style.right = '';
60
61
  iframe.style.width = '100%';
61
62
  iframe.style.height = this.height;
62
63
  iframe.style.zIndex = '999999'; // 6
@@ -70,10 +71,36 @@ export class FooterWidgetBase extends BaseWidget {
70
71
  }
71
72
  return iframe;
72
73
  }
73
- expandIframe() {
74
- this.setIframeHeight('100%');
74
+ expandIframe(iframeRect) {
75
+ if (!this.iframe)
76
+ return;
77
+ if (!this.container) {
78
+ this.setIframeHeight('100%');
79
+ return;
80
+ }
81
+ const rect = iframeRect !== null && iframeRect !== void 0 ? iframeRect : this.iframe.getBoundingClientRect();
82
+ this.iframe.style.position = 'fixed';
83
+ this.iframe.style.left = `${rect.left}px`;
84
+ this.iframe.style.right = 'auto';
85
+ this.iframe.style.width = `${rect.width}px`;
86
+ if (this.position === 'top') {
87
+ this.iframe.style.top = `${rect.top}px`;
88
+ this.iframe.style.bottom = 'auto';
89
+ this.setIframeHeight(`${Math.max(rect.height, window.innerHeight - rect.top)}px`);
90
+ return;
91
+ }
92
+ this.iframe.style.top = '0';
93
+ this.iframe.style.bottom = 'auto';
94
+ this.setIframeHeight(`${Math.max(rect.height, rect.bottom)}px`);
75
95
  }
76
96
  collapseIframe() {
97
+ if (!this.iframe)
98
+ return;
99
+ if (this.container) {
100
+ this.iframe.style.position = 'absolute';
101
+ this.styleIframe(this.iframe);
102
+ return;
103
+ }
77
104
  this.setIframeHeight(this.height);
78
105
  }
79
106
  setIframeHeight(height) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splash-tech/jackpot-sdk",
3
- "version": "3.0.8",
3
+ "version": "3.0.9",
4
4
  "description": "SDK for managing jackpot widgets in iframes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",