mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-18 12:34:25 +08:00
feat(derictive): add clickoutside derictive
This commit is contained in:
parent
af62756c74
commit
7be130ff9b
@ -30,6 +30,13 @@ function dateItem (time, displayTime, selectedTime, currentTime) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given time to display calendar, given the selected time, given current time,
|
||||
* return the date array of display time's month.
|
||||
* @param {Moment} displayTime
|
||||
* @param {Moment} selectedTime
|
||||
* @param {Moment} currentTime
|
||||
*/
|
||||
function dateArray (displayTime, selectedTime, currentTime) {
|
||||
const displayMonth = displayTime.month()
|
||||
/**
|
||||
|
24
packages/directives/clickoutside.js
Normal file
24
packages/directives/clickoutside.js
Normal file
@ -0,0 +1,24 @@
|
||||
import clickoutsideDelegate from '../utils/clickoutsideDelegate'
|
||||
|
||||
const ctx = '@@clickoutsideContext'
|
||||
|
||||
export const clickoutside = {
|
||||
inserted (el, bindings) {
|
||||
if (typeof bindings.value === 'function') {
|
||||
el[ctx] = {
|
||||
handler: bindings.value
|
||||
}
|
||||
clickoutsideDelegate.registerHandler(el, el[ctx].handler)
|
||||
}
|
||||
},
|
||||
update (el, bindings) {
|
||||
if (typeof bindings.value === 'function') {
|
||||
clickoutsideDelegate.unregisterHandler(el, el[ctx].handler)
|
||||
el[ctx].handler = bindings.value
|
||||
clickoutsideDelegate.registerHandler(el, el[ctx].handler)
|
||||
}
|
||||
},
|
||||
unbind (el) {
|
||||
clickoutsideDelegate.unregisterHandler(el, el[ctx].handler)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user