Articles in this section
Category / Section

How to Enable Full Screen Mode in Angular Image Editor?

3 mins read

This article explains how to enable full screen functionality in the Angular Image Editor by adding a custom toolbar item. When the “FullScreen” button is clicked, the editor dynamically resizes and repositions itself to occupy the entire browser viewport.

Step 1: Add a custom toolbar item

To customize the toolbar, use the toolbar property of the ejs-imageeditor component. Add a new item labeled “FullScreen” to the toolbar array.

<ejs-imageeditor #imageEditor (created)="created()" [toolbar]="customToolbar" (toolbarItemClicked)="toolbarItemClicked($event)"></ejs-imageeditor> 
export class AppComponent {

 public customToolbar = [   // Defines the toolbar items including built-in tools
   'Annotate',
   'Line',
   'Rectangle',
   'Text',
   'ZoomIn',
   'ZoomOut',
   { text: 'FullScreen' },  //Adds a custom button with the label "FullScreen"
 ];
} 

Step 2: Toggle full screen on button click

Handle the toolbarItemClicked event to toggle the editor between normal and full screen modes by updating its style properties. Check whether the clicked toolbar item is the custom FullScreen button using args.item.text. If full screen mode is activated, set the image editor element’s position to fixed, with top and left set to 0, and dimensions set to 100vw and 100vh. To revert to normal mode, set the position to relative and dimensions to 100%. Finally, invoke the editor’s update() method to apply the layout changes.

public toolbarItemClicked(args: ClickEventArgs): void {   // Event triggered when any toolbar item is clicked.
    if (args.item.text == 'FullScreen') {  // check whether clicking FullScreen custom button
      this.isFullScreen = !this.isFullScreen;
      if (this.isFullScreen) { 
        (this.imageEditorObj?.element as HTMLElement).style.position = 'fixed';
        (this.imageEditorObj?.element as HTMLElement).style.top = '0';
        (this.imageEditorObj?.element as HTMLElement).style.left = '0';
        (this.imageEditorObj?.element as HTMLElement).style.width = '100vw';
        (this.imageEditorObj?.element as HTMLElement).style.height = '100vh';
      } else {
        (this.imageEditorObj?.element as HTMLElement).style.position =
          'relative';
        (this.imageEditorObj?.element as HTMLElement).style.width = '100%';
        (this.imageEditorObj?.element as HTMLElement).style.height = '100%';
      }
      this.imageEditorObj?.update();
    }
  }

Screenshot

image.png

Live demo

You can try this implementation directly in the following stackBlitz sample:
Live Demo Sample

Conclusion

I hope you enjoyed learning about how to enable full screen mode in Angular Image Editor.

You can refer to our Angular Image Editor’s feature tour page to learn about its other groundbreaking feature representations. You can also explore our Angular Image Editor Documentation to understand how to present and manipulate data.

For current customers, you can check out our Angular components on the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to explore our Angular Image Editor and other Angular components.

If you have any queries or require clarifications, please let us know in the comments below. You can also contact us through our support forums, Direct-Trac or feedback portal, or the feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied