File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 27
27
export let highlightFirstItem = false ;
28
28
export let fitInputWidth = false ;
29
29
30
+ let inputRef;
30
31
let suggestions = [];
31
32
let dropdownWidth = ' ' ;
32
33
let ignoreFocusEvent = false ;
36
37
let tooltipVisible = false ;
37
38
let highlightedIndex = - 1 ;
38
39
$: dark = dark || getContext (' svel-dark' );
40
+ $: suggestionVisible = (suggestions .length > 0 || loading) && activated;
41
+ $: suggestionLoading = ! hideLoading && loading;
39
42
43
+ const onSuggestionShow = () => {
44
+ console .log (12 );
45
+ if (suggestionVisible) {
46
+ dropdownWidth = ` ${ inputRef .offsetWidth } px` ;
47
+ }
48
+ };
40
49
const getData = async (queryString ) => {
41
50
if (suggestionDisabled) return ;
42
51
95
104
aria-controls =" svel-id-6711-108"
96
105
aria-expanded =" false"
97
106
aria-haspopup =" listbox"
107
+ on:beforeShow ={onSuggestionShow }
98
108
role =" combobox"
99
109
>
100
- <SvelInput bind:value on:blur ={handleInputBlur } on:focus ={handleFocus } on:input ={handleInput } />
110
+ <SvelInput
111
+ bind:this ={inputRef }
112
+ bind:value
113
+ on:blur ={handleInputBlur }
114
+ on:focus ={handleFocus }
115
+ on:input ={handleInput }
116
+ />
101
117
</div >
102
118
<div slot =" content" >
103
119
<div role =" region" >
Original file line number Diff line number Diff line change 1
1
<script >
2
2
import Container from ' $lib/container.svelte' ;
3
3
import { createPopperActions } from ' $lib/popper.js' ;
4
- import { getContext , tick } from ' svelte' ;
4
+ import { createEventDispatcher , getContext , tick } from ' svelte' ;
5
5
import a2s from ' @svelement-ui/util-array-2-class-string' ;
6
6
import { onMount } from ' svelte' ;
7
7
import { fade } from ' svelte/transition' ;
8
8
import Portal from ' $lib/portal.svelte' ;
9
9
import { writable } from ' svelte/store' ;
10
10
11
+ const dispatch = createEventDispatcher ();
12
+
11
13
let x = 0 ;
12
14
let y = 0 ;
13
15
const mousemove = (ev ) => {
147
149
let outer;
148
150
149
151
async function doShow () {
152
+ dispatch (' beforeShow' );
150
153
showTooltip = true ;
151
154
152
155
if (autoClose > 0 ) {
161
164
}
162
165
163
166
function doHide () {
167
+ dispatch (' beforeHide' );
164
168
if (contentEl) {
165
169
contentEl .removeEventListener (' mouseover' , show);
166
170
contentEl .removeEventListener (' mouseleave' , hide);
Original file line number Diff line number Diff line change 4
4
let ref;
5
5
let visible = false ;
6
6
let content = ' 1' ;
7
+ let beforeShow = () => {
8
+ console .log (' 1111' );
9
+ };
10
+ let beforeHide = () => {
11
+ console .log (' 2222' );
12
+ };
7
13
</script >
8
14
9
15
<div class =" aaa" >
25
31
<!-- </button>-->
26
32
<!-- <N content="1111" virtualRef={ref} virtualTriggering {visible} />-->
27
33
28
- <N {content }>
34
+ <N {content } on:beforeHide ={ beforeHide } on:beforeShow ={ beforeShow } >
29
35
<button on:click ={() => (content += ' 1' )}>111</button >
30
36
</N >
31
37
</div >
You can’t perform that action at this time.
0 commit comments