Skip to content

Commit d9aa004

Browse files
authored
Merge pull request #2 from murrant/patch-1
Allow offsets to prevent covering UI elements
2 parents 13c285b + 56b7fd7 commit d9aa004

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/template.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ interface Options {
66
fps: number,
77
position: string,
88
direction: string,
9+
x_offset: string,
10+
y_offset: string,
911
}
1012

1113
export default class TemplateFactory implements FlasherInterface {
@@ -14,6 +16,8 @@ export default class TemplateFactory implements FlasherInterface {
1416
fps: 30,
1517
position: 'top-right',
1618
direction: 'top',
19+
x_offset: '0.5em',
20+
y_offset: '0',
1721
};
1822

1923
render(envelope: Envelope): void {
@@ -41,21 +45,21 @@ export default class TemplateFactory implements FlasherInterface {
4145

4246
switch (this.options.position) {
4347
case 'top-left':
44-
container.style.top = '0';
45-
container.style.left = '0.5em';
48+
container.style.top = this.options.y_offset;
49+
container.style.left = this.options.x_offset;
4650
break;
4751
case 'top-right':
48-
container.style.top = '0';
49-
container.style.right = '0.5em';
52+
container.style.top = this.options.y_offset;
53+
container.style.right = this.options.x_offset;
5054
break;
5155
case 'bottom-left':
52-
container.style.bottom = '0';
53-
container.style.left = '0.5em';
56+
container.style.bottom = this.options.y_offset;
57+
container.style.left = this.options.x_offset;
5458
break;
5559
case 'bottom-right':
5660
default:
57-
container.style.bottom = '0';
58-
container.style.right = '0.5em';
61+
container.style.bottom = this.options.y_offset;
62+
container.style.right = this.options.x_offset;
5963
break;
6064
}
6165
document.getElementsByTagName('body')[0].appendChild(container);

0 commit comments

Comments
 (0)