npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ultimate/ngx-fullscreen

v0.0.5

Published

<h1 align="center"> 📺 @ultimate/ngx-fullscreen </h1> <h4 align="center"> <img width="25" valign="middle" src="https://angular.io/assets/images/logos/angular/angular.svg"> Angular Directive that implements the <a href="https://developer.mozilla.org/en

Downloads

757

Readme



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.