Our pure JavaScript Scheduler component


Post by davegould41 »

Hi Team,

For ResourceTimeRanges I see that we have exposed the onResourceTimeRangeMouseOut and onResourceTimeRangeMouseOver events, can we please expose the corresponding mousemove event listener as well?

Is there a workaround to achieve my goal of subscribing to this without the API?


Post by tasnim »

Hi,

You can add a mousemove listener using https://bryntum.com/products/gantt/docs/api/Core/helper/EventHelper#function-addListener-static

EventHelper.addListener(scheduler.element, 'mousemove', (event) => {
    console.log(event);
}, {
    delegate : '.b-sch-resourcetimerange'
});

Best regards,
Tasnim


Post by davegould41 »

Thanks for the response Tasnim,

A couple questions:

  • We pass resourceTimeRange objects in via bryntumschedulerpro's component props (react), Bryntum would be creating the dom elements internally as data changes. The static util you mentioned would seem to need access to that list, and apply these listeners on state changes, which hook do you propose we use for this?
  • Using the delegate would seem to add the event listeners regardless of whether they are Events, ResourceTimeRanges, etc, then conditionally invoke the callback based on truthy css selector, is that true. We'd like to not add mousemove event listeners to elements that dont need it (such as events)
  • Also curious why this isnt exposed as a first class event listener on the ResourceTimeRange object

Thanks for your assistance!


Post by tasnim »

Hi,

For React you can use the useEffect hook for this.

function App() {
    const schedulerRef = useRef<BryntumScheduler>(null);
    useEffect(() => {
        if (schedulerRef.current?.instance) {
            EventHelper.addListener(schedulerRef.current.instance.element, 'mousemove', (event : PointerEvent) => {
                console.log(event);
            }, {
                delegate : '.b-sch-resourcetimerange'
            });
        }
    }, [])

And I've also added a feature request for this to add mouse move event to resourceTimeRange here https://github.com/bryntum/support/issues/9765

If you have any other questions or concerns, please don't hesitate to reach out to us.

Best regards,
Tasnim


Post by davegould41 »

Thanks Tasnim!


Post Reply