Skip to content

Conversation

@jasonnator
Copy link

Summary

This PR introduces enhanced view mode functionality with always-visible view mode buttons, improved navigation
features, and fixes for several long-standing UX issues.

Key Features:

  • Always-visible view mode buttons in the header for instant switching between Day/Week/Month/Year views
  • 🎯 Auto-scroll to today when changing view modes (configurable)
  • 🖱️ Click-and-drag to pan the timeline horizontally
  • 📌 Persistent controls outside the scrollable area
  • 🔧 Multiple bug fixes for scroll behavior, text centering, and layout issues

Related Issues

This PR addresses several community-reported issues:

What's Changed

New Features

  1. View Mode Buttons

    • Always visible in header for better discoverability
    • Clean, modern segmented control design
    • Active state clearly indicates current view
    • Configurable via view_mode_buttons and view_mode_buttons_list options
  2. Drag-to-Pan Navigation

    • Click and drag on empty areas to pan the timeline
    • Smart cursor feedback (grab/grabbing)
    • Doesn't interfere with existing bar interactions
  3. Auto-Scroll to Today

    • Automatically centers on today when changing view modes
    • Configurable via auto_scroll_to_today option
    • Helps users maintain context when switching time scales

Bug Fixes

  • Fixed scroll position jumping when collapsing/expanding tasks
  • Fixed vertical scrolling affecting horizontal position
  • Fixed text centering for bars with collapse buttons
  • Fixed bars being cut off due to incorrect height calculations
  • Fixed short duration bars with text overflow (auto-expand to fit)
  • Corrected collapse button spacing calculations

Configuration

const gantt = new Gantt('#gantt', tasks, {
    // Enable view mode buttons (default: true)
    view_mode_buttons: true,

    // Specify which buttons to show
    view_mode_buttons_list: ['Day', 'Week', 'Month', 'Year'],

    // Auto-scroll to today when changing views (default: true)
    auto_scroll_to_today: true,

    // Show Today button
    today_button: true
});

Examples

Two comprehensive examples have been added to demonstrate the features:
- /examples/enhanced-view-modes/ - Shows the new view mode controls
- /examples/collapsible-tasks/ - Demonstrates the collapsible dependent tasks feature

Backwards Compatibility

- Fully backwards compatible with existing implementations
- Legacy view_mode_select dropdown still supported
- All new features are optional and can be disabled

Testing

The implementation has been tested with:
- Multiple view mode switches
- Large datasets with many tasks
- Collapsible task hierarchies
- Various screen sizes and scroll positions
- Interaction with existing features (drag, resize, etc.)

Screenshots

The view mode buttons appear in the header, making it easy to switch between different time scales while
maintaining scroll position and context.

🤖 Generated with https://claude.com/claude-code

Co-Authored-By: Claude noreply@anthropic.com

jasonnator and others added 5 commits October 6, 2025 18:10
Implemented the ability to collapse and expand dependent tasks in the Gantt chart,
making it easier to manage complex project hierarchies.

Features:
- Tasks with dependents show a collapse/expand button (−/+) on the left
- Clicking the button toggles visibility of all dependent tasks recursively
- Grid automatically adjusts height when tasks are collapsed/expanded
- Bars automatically expand to accommodate button and text
- Buttons move with bars during drag operations

Technical details:
- Added collapsed_tasks Set to track collapsed state
- Implemented recursive dependency tracking
- Dynamic task indexing for proper layout when tasks are hidden
- Smart bar width calculation to prevent text overlap
- Configurable button spacing (button_space parameter)

Includes demo page (collapsible-tasks-demo.html) and documentation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Implemented the ability to collapse and expand dependent tasks in the Gantt chart,
making it easier to manage complex project hierarchies.

Features:
- Tasks with dependents show a collapse/expand button (−/+) on the left
- Clicking the button toggles visibility of all dependent tasks recursively
- Grid automatically adjusts height when tasks are collapsed/expanded
- Bars automatically expand to accommodate button and text
- Buttons move with bars during drag operations

Technical details:
- Added collapsed_tasks Set to track collapsed state
- Implemented recursive dependency tracking
- Dynamic task indexing for proper layout when tasks are hidden
- Smart bar width calculation to prevent text overlap
- Configurable button spacing (button_space parameter)

Includes demo page (collapsible-tasks-demo.html) and documentation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Restructured layout with new gantt-wrapper container
- Moved Today button and view mode buttons to fixed controls bar
- Fixed duplicate button creation issue on view mode changes
- Updated CSS for proper flex layout and z-index layering
- Fixed height calculations for proper bar visibility
- Controls now remain visible while chart content scrolls

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Add click-and-drag to pan timeline horizontally
- Fix vertical scrolling to not affect x-axis (only handle horizontal scroll events)
- Fix height calculations to show all bars without being cut off
- Preserve scroll position when collapsing/expanding tasks
- Fix text centering for bars with collapse buttons (center in available space)
- Fix text positioning for short duration bars (auto-expand bars to fit text)
- Correct collapse button spacing calculations (23px instead of 35px)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable Auto Scrolling to the Left when Gantt Instance Updates or View Mode Changes

1 participant