Angular Directive that implements the Fullscreen API.

Overview

📺 @ultimate/ngx-fullscreen

Angular Directive that implements the Fullscreen API.



Installation

Install via npm i @ultimate/ngx-fullscreen and register the NgxFullscreenModule into an @NgModule.

Live Demo

Check the StackBlitz demo and the example code.

Template API

NgxFullscreenDirective can be used in both template and component (when queried with @ViewChild).

✨ Document or Elements

Entire Document: To fullscreen the document just add ngxFullscreen into a component template. Internally this uses the document.documentElement to enter fullscreen:

<!-- Registers the whole Document -->
<div ngxFullscreen></div>

Elements: Create a Template Ref, e.g. #video for the element you wish to fullscreen and pass it into [ngxFullscreen]:

<!-- Registers just this Element -->
<video 
  src="trailer.mp4" 
  #video
  [ngxFullscreen]="video"
></video>

✨ Enter Fullscreen Mode

Export the ngxFullscreen directive to a Template Ref, e.g. #fullscreen and call enter():

<video 
  src="trailer.mp4" 
  #video
  [ngxFullscreen]="video"
  #fullscreen="ngxFullscreen"
></video>

<button (click)="fullscreen.enter()">
  Enter Fullscreen
</button>

The enter() method also accepts an optional Element to pass a dynamic element.

✨ Exit Fullscreen Mode

Use the exit() method to exit fullscreen mode:

<video 
  src="trailer.mp4" 
  #video
  [ngxFullscreen]="video"
  #fullscreen="ngxFullscreen"
></video>

<button (click)="fullscreen.exit()">
  Exit Fullscreen
</button>

✨ Toggle Fullscreen Mode

Use the toggle() method to toggle fullscreen mode:

<video 
  src="trailer.mp4" 
  #video
  [ngxFullscreen]="video"
  #fullscreen="ngxFullscreen"
></video>

<button (click)="fullscreen.toggle()">
  Toggle Fullscreen
</button>

The toggle() method also accepts an optional Element to pass a dynamic element.

✨ Transition Event

Fires entering and exiting fullscreen mode, using the fullscreenchange event behind-the-scenes:

<video 
  src="trailer.mp4" 
  #video
  [ngxFullscreen]="video"
  #fullscreen="ngxFullscreen"
  (transition)="onTransition($event)"
></video>

The $event is of type NgxFullscreenTransition, contains the fullscreen status and element that is/was fullscreened.

✨ isFullscreen property

Check if fullscreen mode is active via fullscreen.isFullscreen. Returns true or false.

<video 
  src="trailer.mp4" 
  #video
  [ngxFullscreen]="video"
  #fullscreen="ngxFullscreen"
></video>

Fullscreen Mode: {{ fullscreen.isFullscreen ? 'Active' : 'Inactive' }}

✨ Active Class

The fullscreen element will receive an active class is-fullscreen via a @HostBinding.

@ViewChild and Component API

The NgxFullscreenDirective is exposed when queried with @ViewChild, any public methods and properties are also accessible.

✨ Query with @ViewChild

Use a @ViewChild query and call any property as you would inside the template.

import {
  NgxFullscreenDirective, 
  NgxFullscreenTransition
} from '@ultimate/ngx-fullscreen';

@Component({...})
export class AppComponent implements AfterViewInit {
  @ViewChild('fullscreen') fullscreen!: NgxFullscreenDirective;

  onClick() {
    this.fullscreen.toggle();
  }

  enterFullscreen() {
    this.fullscreen.enter();
  }

  exitFullscreen() {
    this.fullscreen.exit();
  }

  ngAfterViewInit() {
    this.fullscreen.transition
      .subscribe((change: NgxFullscreenTransition) => {
        console.log(change); // { isFullscreen: boolean, element: Element }
      });
  }
}

✨ Errors

Fullscreen errors are caught when entering and exiting and are passed from the directive via an errors event:

@Component({...})
export class AppComponent implements AfterViewInit {
  @ViewChild('fullscreen') fullscreen!: NgxFullscreenDirective;

  ngAfterViewInit() {
    this.fullscreen.errors.subscribe((err: string) => {
      // e.g. "Failed to execute 'requestFullscreen' on 'Element'"
      console.log(err);
    });
  }
}

âš  Browser Permissions

Due to the Permissions API, you cannot invoke Fullscreen mode unless it is from a user action, such as a click event.

This means you cannot load a page and behind the scenes invoke a successful Fullscreen request. This is a common source of errors so keep that in mind.

You might also like...

Component infrastructure and Material Design components for Angular

Official components for Angular The Angular team builds and maintains both common UI components and tools to help you build your own custom components

Jan 3, 2023

Angular UI Component Library based on Ant Design

Angular UI Component Library based on Ant Design

NG-ZORRO An enterprise-class Angular UI component library based on Ant Design. English | 简体中文 ✨ Features An enterprise-class UI design system for Angu

Jan 6, 2023

Angular 2 building blocks :package: based on Semantic UI

Angular 2 building blocks :package: based on Semantic UI

Angular2 & Semantic UI Angular2 - Semantic UI Live demo ng-semantic.herokuapp.com Angular 2 Semantic UI version: 2.2.2 Installation npm install ng-sem

Dec 23, 2022

Native Angular components & directives for Lightning Design System

ng-lightning This library contains native Angular components and directives written from scratch in TypeScript using the Lightning Design System CSS f

Dec 8, 2022

Native AngularJS (Angular) directives for Bootstrap

Native AngularJS (Angular) directives for Bootstrap. Smaller footprint (20kB gzipped), no 3rd party JS dependencies (jQuery, bootstrap JS) required. Please read the README.md file before submitting an issue!

Jan 3, 2023

NG Bootstrap - Angular powered Bootstrap widgets

NG Bootstrap - Angular powered Bootstrap widgets Angular widgets built from the ground up using only Bootstrap 4 CSS with APIs designed for the Angula

Dec 24, 2022

🚀 Style and Component Library for Angular

ngx-ui Component & Style Library for Angular by Swimlane. Installing npm i @swimlane/ngx-ui --S Install the project's peer depencencies (moment, codem

Dec 24, 2022

Lightweight, Material Design inspired go to top button. No dependencies. Pure Angular!

Lightweight, Material Design inspired go to top button. No dependencies. Pure Angular!

Angular ScrollTop Button Lightweight, Material Design inspired button for scroll-to-top of the page. No dependencies. Pure Angular! ✓ Angular 13, Ivy

Dec 18, 2022

The best way to quickly integrate Bootstrap 5 Bootstrap 4 or Bootstrap 3 Components with Angular

 The best way to quickly integrate Bootstrap 5 Bootstrap 4 or Bootstrap 3 Components with Angular

ngx-bootstrap The best way to quickly integrate Bootstrap 5 Bootstrap 4 or Bootstrap 3 Components with Angular Links Documentation Release Notes Slack

Jan 8, 2023
Comments
  • Angular 14

    Angular 14

    First of all thanks for that little package.

    Is it possible to upgrade your package to support angular v14?

    At this time i get an error if i want to upgrade my projects dependencies:

    Could not resolve dependency: npm ERR! peer @angular/common@"^13.2.0" from @ultimate/[email protected] npm ERR! node_modules/@ultimate/ngx-fullscreen npm ERR! @ultimate/ngx-fullscreen@"^0.0.5" from the root project

    The package works fine with v14 but the peer dependency errors are a bit annoying.

    opened by bentzibentz 1
  • Can't import the named export 'DOCUMENT' from non EcmaScript module

    Can't import the named export 'DOCUMENT' from non EcmaScript module

    I get several errors like this when trying to build a project using this module:

    Error: ./node_modules/@ultimate/ngx-fullscreen/fesm2015/ultimate-ngx-fullscreen.mjs 127:11-19 Can't import the named export 'DOCUMENT' from non EcmaScript module (only default export is available)

    opened by jbrecht 0
Owner
Ultimate Coursesâ„¢
Become The Ultimate Developer With Our Expert Courses âš¡
Ultimate Coursesâ„¢
tao-web implements the tao-wallet npm package to let you swap between Bitcoin and USD.

tao-web tao-web implements the tao-wallet npm package to let you swap between Bitcoin and USD. tao-wallet currently utilizes the LN Markets API so all

Steven Ellis 7 Nov 12, 2022
Angular Library workspace to creating and testing angular libraries

Library Workspace Run Locally Clone the project https://github.com/sametcelikbicak/library-workspace.git Go to the library project directory cd li

Samet ÇELİKBIÇAK 4 Nov 1, 2022
Sam4Sc - a migration assistant for Angular to SCAM (Single Angular Component Modules) and Standalone Components

Sam4Sc - a migration assistant for Angular to SCAM (Single Angular Component Modules) and Standalone Components

Rainer Hahnekamp 7 Nov 16, 2022
Clarity Angular is a scalable, accessible, customizable, open-source design system built for Angular.

Getting Started Clarity Angular is published as two npm packages: Contains the static styles for building HTML components. Contains the Angular compon

VMware Clarity 145 Dec 29, 2022
An example application that uses file-based routing with Angular, Analog, Vite with the Angular Router

Angular, Vite, and File-based routes This is an example application that uses Angular, Analog, and Vite for file-based routing. Routes are places in t

Brandon 9 Sep 25, 2022
Monorepo for all the tooling related to using ESLint with Angular

Angular ESLint Monorepo for all the tooling which enables ESLint to lint Angular projects

angular-eslint 1.4k Dec 29, 2022
Reactive Extensions for Angular

RxAngular offers a comprehensive toolset for handling fully reactive Angular applications with the main focus on runtime performance and template rendering.

RxAngular 1.5k Jan 5, 2023
Semantic UI Angular Integrations

Semantic-UI-Angular Semantic-UI-Angular is a pure AngularJS 1.x set of directives for Semantic-UI components. We are considering Angular 2 support in

Semantic Org 561 Dec 28, 2022
The code for a set of Angular 6+ components for the PatternFly project.

The code for a set of Angular 6+ components for the PatternFly project. Note that the release/3.x branch supports Angular 4 and 5.

PatternFly 87 Nov 15, 2022
Angular 11 & Bootstrap 5 & Material Design 2.0 UI KIT

MDB 5 Angular Angular 12 & Bootstrap 5 & Material Design 2.0 UI KIT >> Get Started in 4 steps >> MDBAngular 5 Demo 500+ material UI components Super s

MDBootstrap 1.1k Dec 30, 2022