Skip to content

Commit a59695d

Browse files
committed
feat: 🎸 support fullscreenElement when active
to make it work in fullscreen mode we need to append to this element instead of the body
1 parent f0ca018 commit a59695d

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

projects/ngneat/helipopper/src/lib/tippy.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ export class TippyDirective implements OnChanges, AfterViewInit, OnInit {
385385
this.tippyFactory
386386
.create(this.host(), {
387387
allowHTML: true,
388-
appendTo: document.body,
388+
appendTo: document.fullscreenElement || document.body,
389389
...(this.globalConfig.zIndexGetter
390390
? { zIndex: this.globalConfig.zIndexGetter() }
391391
: {}),

src/app/playground/playground.component.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,3 +516,31 @@ <h6>Use text content</h6>
516516
</div>
517517

518518
<hr />
519+
520+
<div>
521+
<h6>Fullscreen Tooltip Test</h6>
522+
<p>This demonstrates tooltips working correctly in fullscreen mode:</p>
523+
524+
<div class="btn-container">
525+
<button
526+
(click)="toggleFullscreen()"
527+
class="btn btn-outline-primary"
528+
tp="fullscreenTooltip"
529+
tpPlacement="bottom"
530+
>
531+
Toggle full screen
532+
</button>
533+
</div>
534+
535+
<div class="mt-3">
536+
<button
537+
class="btn btn-outline-secondary"
538+
tp="This tooltip should work in both normal and fullscreen modes!"
539+
tpPlacement="top"
540+
>
541+
Hover me (works in fullscreen)
542+
</button>
543+
</div>
544+
</div>
545+
546+
<hr />

src/app/playground/playground.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,12 @@ export class PlaygroundComponent {
139139
}
140140

141141
visibility = false;
142+
143+
toggleFullscreen() {
144+
if (!document.fullscreenElement) {
145+
document.documentElement.requestFullscreen();
146+
} else {
147+
document.exitFullscreen();
148+
}
149+
}
142150
}

0 commit comments

Comments
 (0)