Skip to content

Commit

Permalink
Added a sleep of 50ms before adding the mouseup handler to fix
Browse files Browse the repository at this point in the history
issue #8.
  • Loading branch information
farblos committed Jul 27, 2023
1 parent 00b7e28 commit f8ac1cf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/copy-on-select.js
Expand Up @@ -58,6 +58,10 @@ var CopyOnSelect = {
this.copy( t.value.substring( t.selectionStart, t.selectionEnd ) );
},

sleep( ms ) {
return new Promise( ( resolve ) => { setTimeout( resolve, ms ); } );
},

async initialize()
{
// initialize options from storage ...
Expand All @@ -72,6 +76,8 @@ var CopyOnSelect = {
}
);

await this.sleep( 50 );

// add event handler on a target as close as possible to the
// contents
let t = document.body || document || window;
Expand Down

0 comments on commit f8ac1cf

Please sign in to comment.