Skip to content

allowFrom and ignoreFrom with callback functions #1067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tups
Copy link
Contributor

@tups tups commented Aug 7, 2025

This pull request enhances interact.js with callback function support for allowFrom and ignoreFrom options, providing developers with powerful programmatic control over interaction permissions.

Key Features Added

  • Callback Support: Both allowFrom and ignoreFrom now accept callback functions with signature (targetNode: Node, eventTarget: Node) => boolean
  • Enhanced Type Safety: Updated TypeScript definitions across core packages
  • Comprehensive Examples: Added 3 interactive demo pages showcasing different use cases
  • Full Test Coverage: Added test suites for both allowFrom and ignoreFrom callback functionality

New Examples

  • ignoreFrom-callback/ - Basic callback usage with conditional ignore logic
  • allowFrom-callback/ - Role-based access control demonstration
  • combined-callbacks/ - Advanced example combining both options

Technical Changes

  • Updated type definitions in @interactjs/core, @interactjs/auto-start, and related packages
  • Enhanced Interactable.testAllow() and Interactable.testIgnore() methods with function support
  • Maintained full backward compatibility with existing string/element selectors

This enhancement enables sophisticated interaction control scenarios like role-based permissions, conditional drag handles, and complex UI state management while preserving the library's existing API.

tups and others added 3 commits August 7, 2025 12:33
Added support for `ignoreFrom` as a callback function, enabling custom logic to dynamically filter elements during interactions. Includes tests and examples to demonstrate new functionality.
Introduced examples demonstrating the use of `allowFrom` with callback functions for advanced interaction control. Includes new tests and detailed use-case scenarios for role-based and complex logic handling.
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.

1 participant