Skip to content

Commit 32a2239

Browse files
committed
Add mouse down & scroll removal
1 parent 35f45b2 commit 32a2239

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

addon/lint/lint.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
var target = e.target || e.srcElement;
8181
var state = cm.state.lint
8282

83+
if (state.hints) {
84+
remove(state.hints)
85+
}
86+
8387
if (!menus && menus.length > 0) {
8488
return
8589
}
@@ -104,19 +108,19 @@
104108
if (typeof onClick === 'function') {
105109
onClick(e)
106110
}
107-
remove()
111+
remove(hints)
108112
})
109113
}
110114

111-
function remove () {
115+
var removal = function () { setTimeout(function () { remove(hints) }, 100) }
116+
function remove (hints) {
112117
if (hints.parentNode) {
113118
hints.parentNode.removeChild(hints)
114119
}
115120
state.hints = null
116-
}
117-
118-
if (state.hints) {
119-
remove()
121+
122+
cm.off("mousedown", removal)
123+
cm.off("scroll", removal)
120124
}
121125

122126
state.hints = hints
@@ -125,6 +129,10 @@
125129

126130
hints.style.top = top + 5 + 'px'
127131
hints.style.left = left + 20 + 'px'
132+
133+
134+
cm.on("mousedown", removal)
135+
cm.on("scroll", removal)
128136
}
129137

130138
function LintState(cm, options, hasGutter) {

demo/lint.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,13 @@ <h2>Linter Demo</h2>
170170
contextmenu: annotations => ([
171171
{
172172
content: 'Fix me',
173-
onClick (e, annotations) {
173+
onClick (e) {
174174
console.log(annotations)
175175
}
176176
},
177177
{
178178
content: 'Another fixed me',
179-
onClick (e, annotations) {
179+
onClick (e) {
180180
console.log(annotations)
181181
}
182182
}

0 commit comments

Comments
 (0)