← Back to Documentation Index

Nova64 Fullscreen Button Feature

Sponsor

Overview

A universal fullscreen button that appears in the lower-right corner of the canvas for every Nova64 demo. This allows users to quickly toggle fullscreen mode with a single click.

Features

✅ Universal: Appears for all demos automatically
✅ Stylish UI: Neon cyan button with hover effects matching Nova64 theme
✅ Smooth Transitions: Animated hover and fullscreen transitions
✅ Keyboard Support: ESC key exits fullscreen mode
✅ Cross-browser: Works in Chrome, Firefox, Safari, Edge
✅ Icon Changes: Shows expand icon (⛶) normally, compress icon (⛉) in fullscreen
✅ Transparent Background: Blurred backdrop for modern glass effect

Usage

For Users:

  1. Enter Fullscreen:

    • Click the button in the lower-right corner
    • Or use F11 (browser default)
  2. Exit Fullscreen:

    • Click the button again
    • Or press ESC key
    • Or press F11 again

For Developers:

The fullscreen button is automatically created when the Nova64 runtime initializes. No setup needed in individual demos!

// In main.js - already configured!
import { createFullscreenButton } from '../runtime/fullscreen-button.js';

const canvas = document.getElementById('screen');
globalThis.fullscreenButton = createFullscreenButton(canvas);

Implementation Details

File: runtime/fullscreen-button.js

The fullscreen button:

Styling

Position: Fixed (lower-right corner)
Size: 48px × 48px
Border: 2px solid cyan (#00ffff)
Background: Semi-transparent dark with blur effect
Shadow: Neon cyan glow
Z-index: 9999 (always on top)

Browser Compatibility

Uses standard Fullscreen API with fallbacks:

Technical Architecture

Class: FullscreenButton

class FullscreenButton {
  constructor(canvas)
  createButton()           // Creates DOM element with styles
  attachListeners()        // Sets up click and keyboard handlers
  toggleFullscreen()       // Toggles between fullscreen/normal
  enterFullscreen()        // Enters fullscreen mode
  exitFullscreen()         // Exits fullscreen mode
  handleFullscreenChange() // Syncs state with browser
  updateButton()           // Updates icon based on state
  destroy()                // Cleanup (if needed)
}

State Management

this.isFullscreen = false; // Tracks current state

State is automatically synchronized when:

Customization

If you need to customize the button appearance, edit runtime/fullscreen-button.js:

// Change position
bottom: '20px',    // Distance from bottom
right: '20px',     // Distance from right

// Change size
width: '48px',
height: '48px',

// Change colors
border: '2px solid #00ffff',  // Cyan border
color: '#00ffff',              // Cyan icon

// Change background
background: 'rgba(21, 24, 34, 0.9)',  // Dark semi-transparent

ESC Key Behavior

The ESC key is handled at two levels:

  1. Browser Level: Native fullscreen ESC handling
  2. Button Level: Custom ESC listener that calls exitFullscreen()

Both work together to ensure ESC always exits fullscreen mode.

Examples

Button in Different States

Normal Mode:

┌──────────────────┐
│        ⛶         │  ← Expand icon
└──────────────────┘

Fullscreen Mode:

┌──────────────────┐
│        ⛉         │  ← Compress icon
└──────────────────┘

Hover Effect

Testing

Test Checklist

Browser Testing

Test in:

Canvas Behavior in Fullscreen

When entering fullscreen:

Performance

Accessibility

Troubleshooting

Button doesn't appear

Fullscreen doesn't work

ESC doesn't exit fullscreen

Button blocked by game UI

Future Enhancements

Potential additions:

Integration with Demos

No changes needed in individual demos! The button is globally available.

If a demo needs to disable it:

// In your demo's init()
if (globalThis.fullscreenButton) {
  globalThis.fullscreenButton.destroy();
}

If a demo needs custom fullscreen handling:

// Access the button instance
const fsBtn = globalThis.fullscreenButton;

// Check state
if (fsBtn.isFullscreen) {
  console.log('Currently in fullscreen');
}

// Programmatically toggle
fsBtn.toggleFullscreen();

Files Modified

  1. Created: runtime/fullscreen-button.js

    • New fullscreen button class
    • 150+ lines of code
  2. Modified: src/main.js

    • Added import statement
    • Created button instance
    • 2 lines added

Summary

✅ Universal fullscreen button added to all Nova64 demos
✅ ESC key support for easy exit
✅ Modern UI with neon effects matching Nova64 theme
✅ Zero configuration needed in individual demos
✅ Cross-browser compatible with fallbacks
✅ Performance optimized with minimal overhead

Status: ✅ Production Ready
Last Updated: October 26, 2025
Version: 1.0