MHoverable
On this page
- MHoverable ⇐
Trait
- MHoverable()
- mouseMove(mouseEvent)
- onMouseEnter(mouseEvent)
- onMouseLeave(mouseEvent)
- isHovered(mouseEvent) ⇒
boolean
- getHoverableChildren(mouseEvent) ⇒
Array
- _getHoverableChildren(mouseEvent, hoverableChildren) ⇒
Array
- _getSortedHoverableCandidates() ⇒
Array.<Object.<id, index>>
- _filterHoverableCandidates(id) ⇒
boolean
MHoverable ⇐ Trait
Kind: global class
Extends: Trait
Properties
Name | Type | Description |
---|---|---|
isHoverable | boolean | Feature flag |
isHover | boolean | is set to true when the view is hovered |
hoverEnabled | Object | true by default - if it is false, the view is unHoverable: it is no longer concerned by hover events, nor its children |
- MHoverable ⇐
Trait
- new MHoverable()
- .mouseMove(mouseEvent)
- .onMouseEnter(mouseEvent)
- .onMouseLeave(mouseEvent)
- .isHovered(mouseEvent) ⇒
boolean
- .getHoverableChildren(mouseEvent) ⇒
Array
- ._getHoverableChildren(mouseEvent, hoverableChildren) ⇒
Array
- ._getSortedHoverableCandidates() ⇒
Array.<Object.<id, index>>
- ._filterHoverableCandidates(id) ⇒
boolean
MHoverable()
Mark a view as being Hoverable
mouseMove(mouseEvent)
Mouse move on the screen
set state of the views that are hover
call onMouseEnter (extension point)
remove state of the view that were hover
call onMouseLeave (extension point)
Kind: instance method of MHoverable
Param | Type |
---|---|
mouseEvent | MouseEvent |
onMouseEnter(mouseEvent)
Extension point
Kind: instance method of MHoverable
Param | Type |
---|---|
mouseEvent | MouseEvent |
onMouseLeave(mouseEvent)
Extension point
Kind: instance method of MHoverable
Param | Type |
---|---|
mouseEvent | MouseEvent |
isHovered(mouseEvent) ⇒ boolean
Return true if mouse in hover the view The view must have it’s MHoverable#hoverEnabled set to true.
Kind: instance method of MHoverable
Param | Type |
---|---|
mouseEvent | MouseEvent |
getHoverableChildren(mouseEvent) ⇒ Array
Find the views that are candidates to handle mouse move.
Kind: instance method of MHoverable
Param | Type |
---|---|
mouseEvent | MouseEvent |
_getHoverableChildren(mouseEvent, hoverableChildren) ⇒ Array
Get all hoverable element at position (mouseEvent.pageX ; mouseEvent.pageY)
Try to find all candidates that has been hovered. It iterates over the view hierarchy to find the hovered view’s (ie the views that are within of the mouseEvent coordinates)
Examples
+————————————+ | ViewA | | +—————————–+ | | | | | | | ButtonA ButtonB ButtonC | | | | | | | +—————————–+ | | | +————————————+ ViewA, ButtonA, ButtonB & ButtonC are all hoverable
mouse on ButtonA => hoverableChildren = [buttonA, ViewA] mouse on ButtonB => hoverableChildren = [buttonB, ViewA] mouse on ButtonC => hoverableChildren = [buttonC, ViewA] mouse outside ButtonA & ButtonB & ButtonC => clickedChildren = [ViewA]
Kind: instance method of MHoverable
Access: protected
Param | Type | Description |
---|---|---|
mouseEvent | MouseEvent | the mouse event |
hoverableChildren | Array |
_getSortedHoverableCandidates() ⇒ Array.<Object.<id, index>>
Get the children that are candidates to be hoverable. Keep children that are hoverable, sort children by layer then declaration order
Remarks: you may override these method to filter additional view(s), for example
Be careful with the format of the returned object
Kind: instance method of MHoverable
Returns: Array.<Object.<id, index>>
- An array of object, where id key value is the child id and index key value the order of declaration
Access: protected
_filterHoverableCandidates(id) ⇒ boolean
Called when the view is looking for hoverable candidates The method is called on children that are hoverable (isHoverable === true) It must returns true if the candidate must be kept, false otherwise
You can override these method
Kind: instance method of MHoverable
Returns: boolean
- true if the child must be kept
Access: protected
Param | Type | Description |
---|---|---|
id | string | the id of the child |
Example
_filterHoverableCandidates: function(id) {
if (id === "modalPopup" && this.modalPopup.isVisible !== true) {
// exclude modalPopup if not shown
return false;
}
if (id !== "modalPopup" && this.modalPopup.isVisible === true) {
// keep only modalPopup if shown
return false;
}
return true;
}