Skip to content

Commit

Permalink
Fix: make mouse over work on refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
eight04 committed Feb 15, 2024
1 parent c74ea14 commit e9b676e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
16 changes: 8 additions & 8 deletions dist/linkify-plus-plus.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3642,16 +3642,17 @@ const triggers = [
{
enabled: pref => pref.get("triggerByHover"),
trigger: options => {
document.addEventListener("mouseover", function(e){
// catch the first mousemove event since mouseover doesn't fire at page refresh
document.addEventListener("mousemove", handle, {passive: true, once: true});
document.addEventListener("mouseover", handle, { passive: true });

function handle(e) {
const el = e.target;
console.log(el, processedNodes.has(el));
if (validRoot(el, options.validator)) {
processedNodes.add(el);
linkify({...options, root: el, recursive: false});
}
}, {
passive: true
});
}
}
},
{
Expand Down Expand Up @@ -3703,7 +3704,6 @@ function createValidator({includeElement, excludeElement}) {
if (processedNodes.has(node)) {
return false;
}
// processedNodes.add(node);

if (node.isContentEditable) {
return false;
Expand Down Expand Up @@ -3835,8 +3835,8 @@ function getMessageFactory() {
"optionsMailLabel": "Match email address.",
"optionsNewTabLabel": "Open links in new tabs.",
"optionsStandaloneLabel": "The link must be surrounded by whitespaces.",
"optionsTriggerLabel": "Trigger linkify on",
"optionsTriggerByPageLoadLabel": "Page load",
"optionsTriggerLabel": "Trigger linkifier when",
"optionsTriggerByPageLoadLabel": "Page loaded",
"optionsTriggerByNewNodeLabel": "New elements added",
"optionsTriggerByHoverLabel": "Mouse over",
"optionsTriggerByClickLabel": "Mouse click",
Expand Down
11 changes: 6 additions & 5 deletions src/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@ const triggers = [
{
enabled: pref => pref.get("triggerByHover"),
trigger: options => {
document.addEventListener("mouseover", function(e){
// catch the first mousemove event since mouseover doesn't fire at page refresh
document.addEventListener("mousemove", handle, {passive: true, once: true});
document.addEventListener("mouseover", handle, { passive: true });

function handle(e) {
const el = e.target;
console.log(el, processedNodes.has(el))
if (validRoot(el, options.validator)) {
processedNodes.add(el);
linkify({...options, root: el, recursive: false});
}
}, {
passive: true
});
}
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/static/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"message": "The link must be surrounded by whitespaces."
},
"optionsTriggerLabel": {
"message": "Trigger linkify on"
"message": "Trigger linkifier when"
},
"optionsTriggerByPageLoadLabel": {
"message": "Page load"
"message": "Page loaded"
},
"optionsTriggerByNewNodeLabel": {
"message": "New elements added"
Expand Down

0 comments on commit e9b676e

Please sign in to comment.