Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 |
import { VNodeDirective } from 'vue/types/vnode' |
|
2 |
|
|
3 |
interface ResizeVNodeDirective extends VNodeDirective { |
|
4 |
value?: () => void |
|
5 |
options?: boolean | AddEventListenerOptions |
|
6 |
}
|
|
7 |
|
|
8 | 1 |
function inserted (el: HTMLElement, binding: ResizeVNodeDirective) { |
9 | 1 |
const callback = binding.value! |
10 |
const options = binding.options || { passive: true } |
|
11 |
|
|
12 | 1 |
window.addEventListener('resize', callback, options) |
13 | 1 |
el._onResize = { |
14 |
callback, |
|
15 |
options, |
|
16 |
}
|
|
17 |
|
|
18 |
if (!binding.modifiers || !binding.modifiers.quiet) { |
|
19 | 1 |
callback() |
20 |
}
|
|
21 |
}
|
|
22 |
|
|
23 | 1 |
function unbind (el: HTMLElement) { |
24 |
if (!el._onResize) return |
|
25 |
|
|
26 | 1 |
const { callback, options } = el._onResize |
27 | 1 |
window.removeEventListener('resize', callback, options) |
28 | 1 |
delete el._onResize |
29 |
}
|
|
30 |
|
|
31 | 1 |
export const Resize = { |
32 |
inserted, |
|
33 |
unbind, |
|
34 |
}
|
|
35 |
|
|
36 | 1 |
export default Resize |
Read our documentation on viewing source code .