Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

Commit 517bec8

Browse files
ankituCaerusKaru
authored andcommitted
feat: add ability to disable overlay (#101)
This commit adds disable freeze overlay functionality, usage `disableOverlay` option (defaults to false) can be passed to the preboot initial config as follows: ``` PrebootModule.withConfig({ appRoot: 'app-root', disableOverlay: true }) ```
1 parent d2c5026 commit 517bec8

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ replayer.replayAll();
9999
* `buffer` (default `true`) - If true, preboot will attempt to buffer client rendering to an extra hidden div. In most
100100
cases you will want to leave the default (i.e. true) but may turn off if you are debugging an issue.
101101
* `minify` (deprecated) - minification has been removed in v6. Minification should be handled by the end-user
102+
* `disableOverlay` (default `true`) - If true, freeze overlay would not get injected in the DOM.
102103
* `eventSelectors` (defaults below) - This is an array of objects which specify what events preboot should be listening for
103104
on the server view and how preboot should replay those events to the client view.
104105
See Event Selector section below for more details but note that in most cases, you can just rely on the defaults

src/lib/api/event.recorder.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ export function getAppRoot(
142142
// else the client root is the same as the server
143143
root.clientNode = opts.buffer ? createBuffer(root) : root.serverNode;
144144

145-
// create an overlay that can be used later if a freeze event occurs
146-
root.overlay = createOverlay(_document);
145+
// create an overlay if not disabled ,that can be used later if a freeze event occurs
146+
if (!opts.disableOverlay) {
147+
root.overlay = createOverlay(_document);
148+
}
147149

148150
return root;
149151
}
@@ -205,6 +207,7 @@ export function createListenHandler(
205207
// IE uses a prefixed `matches` version
206208
const matches = _document.documentElement.matches ||
207209
_document.documentElement.msMatchesSelector;
210+
const opts = prebootData.opts;
208211

209212
return function(event: DomEvent) {
210213
const node: Element = event.target;
@@ -262,8 +265,8 @@ export function createListenHandler(
262265
prebootData.activeNode = undefined;
263266
}
264267

265-
// if we are freezing the UI
266-
if (eventSelector.freeze) {
268+
// if overlay is not disabled and we are freezing the UI
269+
if (opts && !opts.disableOverlay && eventSelector.freeze) {
267270
const overlay = root.overlay as HTMLElement;
268271

269272
// show the overlay

src/lib/api/inline.preboot.code.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const initFunctionName = 'prebootInitFn';
3636
export const defaultOptions = <PrebootOptions>{
3737
buffer: true,
3838
replay: true,
39+
disableOverlay: false,
3940

4041
// these are the default events are are listening for an transferring from
4142
// server view to client view

src/lib/common/preboot.interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface PrebootOptions {
2929
eventSelectors?: EventSelector[]; // when any of these events occur, they are recorded
3030
appRoot: string | string[]; // define selectors for one or more server roots
3131
replay?: boolean;
32+
disableOverlay?: boolean;
3233
}
3334

3435
// our wrapper around DOM events in preboot

0 commit comments

Comments
 (0)