File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ // v-b-hover directive
2
+ import { isBrowser } from '../../utils/env'
3
+ import { EVENT_OPTIONS_NO_CAPTURE , eventOn , eventOff } from '../../utils/events'
4
+ import { isFunction } from '../../utils/inspect'
5
+
6
+ // --- Constants ---
7
+
8
+ const PROP = '__BV_hover_handler__'
9
+ const MOUSEENTER = 'mouseenter'
10
+ const MOUSELEAVE = 'mouseleave'
11
+
12
+ // --- Directive bind/unbind/update handler ---
13
+
14
+ const directive = ( el , { value : callback } ) {
15
+ if ( isBrowser && isFunction ( el [ PROP ] && el [ PROP ] !== callback ) {
16
+ eventOff ( el , MOUSEENTER , el [ PROP ] , EVENT_OPTIONS_NO_CAPTURE )
17
+ eventOff ( el , MOUSELEAVE , el [ PROP ] , EVENT_OPTIONS_NO_CAPTURE )
18
+ }
19
+ if ( isBrowser && isFunction ( callback ) && isBrowser ) {
20
+ el [ PROP ] = evt => {
21
+ callback ( evt . type === 'mouseenter' )
22
+ }
23
+ eventOn ( el , MOUSEENTER , el [ PROP ] , EVENT_OPTIONS_NO_CAPTURE )
24
+ eventOn ( el , MOUSELEAVE , el [ PROP ] , EVENT_OPTIONS_NO_CAPTURE )
25
+ }
26
+ }
27
+
28
+ // VBHover directive
29
+
30
+ export const VBHover = {
31
+ bind : directive ,
32
+ componentUpdated : directive ,
33
+ unbind ( el ) {
34
+ directive ( el , { value : null }
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments