Skip to content

Commit

Permalink
Add mouse enter and mouse leave events
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii committed Aug 13, 2024
1 parent 34f6cc5 commit dc98ea2
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 5 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,35 @@ public function eventDidMount(): string

The JavaScript code returned by `eventDidMount()` will be added to [the FullCalendar's `eventDidMount` event render hook](https://fullcalendar.io/docs/event-render-hooks).
## Event Mouse Enter and Mouse Leave
You can add some custom behavior when the user hovers over the event via JavaScript on the `eventMouseEnter` and `eventMouseLeave` methods:
```php
public function eventMouseEnter(): string
{
return <<<JS
function({ event, el, jsEvent, view }){
// Write your custom implementation here
// Will be triggered when the user hovers over the event
}
JS;
}
public function eventMouseLeave(): string
{
return <<<JS
function({ event, el, jsEvent, view }){
// Write your custom implementation here
// Will be triggered when the user leaves the event
}
JS;
}
```
The JavaScript code returned by `eventMouseEnter()` and `eventMouseLeave()` will be added to [the FullCalendar's `eventMouseEnter` and `eventMouseLeave` event hovering hook](https://fullcalendar.io/docs/event-clicking-hovering).


## Adding the widget to a Blade view

Follow the [Filament Docs](https://filamentphp.com/docs/3.x/widgets/adding-a-widget-to-a-blade-view) to know how to add the widget to a Blade view.
Expand Down
10 changes: 5 additions & 5 deletions dist/filament-fullcalendar.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions resources/js/filament-fullcalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export default function fullcalendar({
eventContent,
eventDidMount,
eventWillUnmount,
eventMouseEnter,
eventMouseLeave,
}) {
return {
init() {
Expand All @@ -50,6 +52,8 @@ export default function fullcalendar({
eventContent,
eventDidMount,
eventWillUnmount,
eventMouseEnter,
eventMouseLeave,
events: (info, successCallback, failureCallback) => {
this.$wire.fetchEvents({ start: info.startStr, end: info.endStr, timezone: info.timeZone })
.then(successCallback)
Expand Down
28 changes: 28 additions & 0 deletions src/Widgets/Concerns/InteractsWithRawJS.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,32 @@ public function eventWillUnmount(): string
null
JS;
}

/**
* Triggered when the user mouses over an event. Similar to the native mouseenter.
*
* @see https://fullcalendar.io/docs/eventMouseEnter
*
* @return string
*/
public function eventMouseEnter(): string
{
return <<<JS
null
JS;
}

/**
* Triggered when the user mouses out of an event. Similar to the native mouseleave.
*
* @see https://fullcalendar.io/docs/eventMouseLeave
*
* @return string
*/
public function eventMouseLeave(): string
{
return <<<JS
null
JS;
}
}

0 comments on commit dc98ea2

Please sign in to comment.