Skip to content

A digital magazine built with flipbook visualization and turnjs

License

Notifications You must be signed in to change notification settings

IamPrime/magazine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digital Magazine Application

A modern, component-based digital magazine viewer with smooth page-turning animations, fullscreen support, and cross-platform compatibility.

Features

  • 🏗️ Modern Architecture - Component-based ES6 classes with event-driven communication
  • 📱 Cross-Platform - Optimized for iOS, Android, Windows Phone, and Desktop
  • 🔄 Smooth Animations - Page-turning effects with turn.js integration
  • 📊 Smart Preloading - Progressive image loading with real-time progress
  • 🖥️ Fullscreen Mode - Cross-browser fullscreen support
  • ⌨️ Multiple Navigation - Touch, mouse, and keyboard controls
  • 🎨 Loading Experience - Animated loading indicators
  • 📱 Mobile Optimized - iOS bounce prevention and touch handling

Quick Start

# Clone and serve
git clone [repository-url]
cd magazine-app

# Serve with any web server
python -m http.server 8000
# or
npx http-server

Open http://localhost:8000 in your browser.

Architecture

Component-Based Design

MagazineApp (Main Controller)
├── DeviceManager (Platform Detection)
├── ImagePreloader (Asset Management) 
├── LoadingIndicator (Progress UI)
├── MagazineViewer (Core Functionality)
├── NavigationCtrls (Navigation UI)
└── FullscreenManager (Fullscreen API)

Event-Driven Communication

ImagePreloader → progress → LoadingIndicator
ImagePreloader → complete → MagazineApp
NavigationCtrls → goToPage → MagazineViewer
MagazineViewer → pageTurned → NavigationCtrls

Project Structure

js/
├── components/              # Modern component architecture
│   ├── MagazineApp.js          # Main application controller
│   ├── MagazineViewer.js       # Core magazine viewing & turn.js integration
│   ├── NavigationCtrls.js      # Navigation controls & user input
│   ├── FullscreenManager.js    # Cross-browser fullscreen API
│   ├── DeviceManager.js        # Device detection & optimization
│   ├── ImagePreloader.js       # Progressive image loading
│   └── LoadingIndicator.js     # Loading UI & progress display
├── utils/
│   └── EventEmitter.js         # Custom event system
├── jquery.min.js               # jQuery (turn.js dependency)
└── modernizr.2.5.3.min.js     # Feature detection

css/
├── basic.css                   # Core styles
└── fullscreen.css             # Fullscreen-specific styles

image/                          # Magazine page images
├── 001.jpg → 026.jpg          # Sequential page images
└── 000.png                    # Logo/favicon

Dependencies

Required

  • jQuery - Required for turn.js functionality
  • turn.js - Page turning animations (not sure if this still works with this app)
  • Modernizr - Feature detection

Browser Support

  • Modern browsers with ES6 class support
  • Mobile browsers (iOS Safari 10+, Chrome Mobile 60+)
  • Desktop browsers (Chrome 60+, Firefox 55+, Safari 10+, Edge 79+)

API Documentation

MagazineApp

Main application orchestrator.

const app = new MagazineApp();

Properties:

  • imageUrls: string[] - Magazine page image URLs (26 pages)
  • components: object - All component instances

Events:

  • loadingComplete - All images loaded, viewer ready
  • ready - Application fully initialized

DeviceManager

Platform detection and device-specific optimizations.

const deviceManager = new DeviceManager();

Methods:

  • detectDevice(): string - Returns 'android'|'ios'|'windows'|'desktop'
  • getDeviceType(): string - Get current device type
  • disableIOSBounce(): void - Disable iOS elastic scrolling

ImagePreloader

Progressive image loading with progress tracking.

const preloader = new ImagePreloader(imageUrls);
preloader.load();

Events:

// Progress updates
preloader.on('progress', (data) => {
  // data: { percentage: 0-100, loaded: number, total: number }
});

// Loading complete
preloader.on('complete', (data) => {
  // data: { loadingTime: ms, totalImages: number }
});

MagazineViewer

Core magazine functionality with turn.js integration.

const viewer = new MagazineViewer(imageUrls);

Methods:

  • setupFlipbook(): void - Initialize turn.js flipbook
  • goToPage(page: number): void - Navigate to specific page
  • nextPage(): void - Go to next page
  • previousPage(): void - Go to previous page

Events:

  • pageTurning - Page turn animation starting
  • pageTurned - Page turn completed with { page, view }
  • ready - Viewer initialized and ready

NavigationControls

User interface for magazine navigation.

const controls = new NavigationControls(totalPages);

Methods:

  • updateCurrentPage(page: number): void - Update page display

Events:

  • goToFirst - Navigate to first page
  • goToLast - Navigate to last page
  • previousPage - Go to previous page
  • nextPage - Go to next page
  • goToPage - Navigate to specific page number

FullscreenManager

Cross-browser fullscreen functionality.

const fullscreen = new FullscreenManager();

Methods:

  • toggle(): void - Toggle fullscreen mode
  • enter(): void - Enter fullscreen
  • exit(): void - Exit fullscreen
  • isInFullscreen(): boolean - Check fullscreen status

LoadingIndicator

Loading progress display and animations.

const indicator = new LoadingIndicator();

Methods:

  • show(): void - Show loading overlay
  • hide(): void - Hide loading overlay
  • updateProgress(percentage: number): void - Update progress (0-100)

Setup & Configuration

Basic Setup

  1. Prepare Images

    image/
    ├── 001.jpg  # First page
    ├── 002.jpg  # Second page
    └── ...      # Up to 026.jpg
    

    It can hold as many images as you'll like to use.

  2. Add turn.js Dependency

    <script src="/js/turn.js"></script>
  3. Customize Image URLs

    this.imageUrls = [
      "/image/001.jpg",
      "/image/002.jpg",
      // Add your images here
    ];

Advanced Configuration

Turn.js Settings (in MagazineViewer.js):

$('.flipbook').turn({
  width: 800,
  height: 600,
  autoCenter: true,
  duration: 1000,        // Animation speed
  acceleration: true,    // Hardware acceleration
  gradients: true,      // Page shadows
  elevation: 50         // 3D effect depth
});

Device-Specific Behavior:

// Customize in DeviceManager.js
if (this.deviceType === 'ios') {
  this.disableIOSBounce(); // Prevent elastic scrolling
}

Usage Examples

Basic Initialization

document.addEventListener('DOMContentLoaded', () => {
  const app = new MagazineApp();
  document.getElementById('magazine-app').appendChild(app.element);
});

Custom Event Handling

const app = new MagazineApp();

app.components.viewer.on('pageTurned', (data) => {
  console.log(`Now on page ${data.page}`);
  // Custom page change logic
});

app.components.preloader.on('progress', (data) => {
  console.log(`Loading: ${data.percentage}%`);
  // Custom progress handling
});

Programmatic Navigation

// Navigate to specific page
app.components.viewer.goToPage(5);

// Go to next page
app.components.viewer.nextPage();

// Toggle fullscreen
app.components.fullscreenManager.toggle();

Development

Adding New Components

  1. Create Component

    class NewComponent extends EventEmitter {
      constructor(options) {
        super();
        this.options = options;
        this.init();
      }
      
      init() {
        // Component logic
      }
    }
  2. Register in MagazineApp

    this.components = {
      // existing components...
      newComponent: new NewComponent(options)
    };
  3. Set up Communication

    this.components.newComponent.on('event', (data) => {
      // Handle component events
    });

Event System

All components extend EventEmitter for consistent communication:

// Emit events
this.emit('eventName', { data: 'value' });

// Listen for events  
component.on('eventName', (data) => {
  // Handle event
});

// Remove listeners
component.off('eventName', callback);

Performance Optimization

Image Optimization

  • Use progressive JPEG format
  • Optimize file sizes (recommended: 200-500KB per page)
  • Consider WebP format for modern browsers

Memory Management

  • Images are preloaded but not cached indefinitely
  • Event listeners are properly managed
  • Mobile-specific optimizations included

Loading Strategy

  • Progressive loading with visual feedback
  • Error handling for failed image loads
  • Graceful degradation on slow connections

Browser Compatibility

Fully Supported

  • Chrome 60+ (Desktop/Mobile)
  • Firefox 55+ (Desktop/Mobile)
  • Safari 10+ (Desktop/Mobile)
  • Edge 79+ (Chromium-based)

Partially Supported

  • Internet Explorer 11 (limited ES6 support)
  • Older mobile browsers (may need polyfills)

Troubleshooting

Common Issues

Images not loading:

  • Verify image paths in MagazineApp.js
  • Check web server static file serving
  • Ensure proper CORS headers if serving from different domain

Turn.js not working:

  • Add <script src="/js/turn.js"></script> to HTML
  • Verify jQuery loads before turn.js
  • Check browser console for JavaScript errors

Mobile touch issues:

  • Test on actual devices, not just browser dev tools
  • Verify touch event handling in NavigationControls
  • Check iOS bounce prevention is working

Performance issues:

  • Monitor memory usage on mobile devices
  • Optimize image file sizes
  • Consider reducing animation duration

Debug Mode

Enable console logging:

// Add to MagazineApp constructor
this.debug = true;

// Components will log events when debug is enabled

License

MIT License


Note: This application uses a modern, component-based architecture with no legacy code dependencies. All functionality is implemented through ES6 classes with event-driven communication.

About

A digital magazine built with flipbook visualization and turnjs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published