@@ -25,40 +25,29 @@ class ElementOverlay {
2525 */
2626 constructor ( options ) {
2727 // Create and style the overlay element.
28- this . overlay = document . createElement ( "div" ) ;
29- this . overlay . className = options . className || "_ext-element-overlay" ;
30- this . overlay . style . background =
31- ( options . style && options . style . background ) || "rgba(250, 240, 202, 0.2)" ;
32- this . overlay . style . borderColor =
33- ( options . style && options . style . borderColor ) || "#F95738" ;
34- this . overlay . style . borderStyle =
35- ( options . style && options . style . borderStyle ) || "solid" ;
36- this . overlay . style . borderRadius =
37- ( options . style && options . style . borderRadius ) || "1px" ;
38- this . overlay . style . borderWidth =
39- ( options . style && options . style . borderWidth ) || "1px" ;
40- this . overlay . style . boxSizing =
41- ( options . style && options . style . boxSizing ) || "border-box" ;
42- this . overlay . style . cursor =
43- ( options . style && options . style . cursor ) || "crosshair" ;
44- this . overlay . style . position =
45- ( options . style && options . style . position ) || "absolute" ;
46- this . overlay . style . zIndex =
47- ( options . style && options . style . zIndex ) || "2147483647" ;
48- this . overlay . style . margin =
49- ( options . style && options . style . margin ) || "0px" ;
50- this . overlay . style . padding =
51- ( options . style && options . style . padding ) || "0px" ;
28+ this . overlay = document . createElement ( 'div' ) ;
29+ this . overlay . className = options . className || '_ext-element-overlay' ;
30+ this . overlay . style . background = ( options . style && options . style . background ) || 'rgba(250, 240, 202, 0.2)' ;
31+ this . overlay . style . borderColor = ( options . style && options . style . borderColor ) || '#F95738' ;
32+ this . overlay . style . borderStyle = ( options . style && options . style . borderStyle ) || 'solid' ;
33+ this . overlay . style . borderRadius = ( options . style && options . style . borderRadius ) || '1px' ;
34+ this . overlay . style . borderWidth = ( options . style && options . style . borderWidth ) || '1px' ;
35+ this . overlay . style . boxSizing = ( options . style && options . style . boxSizing ) || 'border-box' ;
36+ this . overlay . style . cursor = ( options . style && options . style . cursor ) || 'crosshair' ;
37+ this . overlay . style . position = ( options . style && options . style . position ) || 'absolute' ;
38+ this . overlay . style . zIndex = ( options . style && options . style . zIndex ) || '2147483647' ;
39+ this . overlay . style . margin = ( options . style && options . style . margin ) || '0px' ;
40+ this . overlay . style . padding = ( options . style && options . style . padding ) || '0px' ;
5241
5342 // Create a container that will host a Shadow DOM.
54- this . shadowContainer = document . createElement ( " div" ) ;
55- this . shadowContainer . className = " _ext-element-overlay-container" ;
56- this . shadowContainer . style . position = " absolute" ;
57- this . shadowContainer . style . top = " 0px" ;
58- this . shadowContainer . style . left = " 0px" ;
59- this . shadowContainer . style . margin = " 0px" ;
60- this . shadowContainer . style . padding = " 0px" ;
61- this . shadowRoot = this . shadowContainer . attachShadow ( { mode : " open" } ) ;
43+ this . shadowContainer = document . createElement ( ' div' ) ;
44+ this . shadowContainer . className = ' _ext-element-overlay-container' ;
45+ this . shadowContainer . style . position = ' absolute' ;
46+ this . shadowContainer . style . top = ' 0px' ;
47+ this . shadowContainer . style . left = ' 0px' ;
48+ this . shadowContainer . style . margin = ' 0px' ;
49+ this . shadowContainer . style . padding = ' 0px' ;
50+ this . shadowRoot = this . shadowContainer . attachShadow ( { mode : ' open' } ) ;
6251 }
6352
6453 /**
@@ -99,14 +88,14 @@ class ElementOverlay {
9988 * Enables pointer events on the overlay.
10089 */
10190 captureCursor ( ) {
102- this . overlay . style . pointerEvents = " auto" ;
91+ this . overlay . style . pointerEvents = ' auto' ;
10392 }
10493
10594 /**
10695 * Disables pointer events on the overlay.
10796 */
10897 ignoreCursor ( ) {
109- this . overlay . style . pointerEvents = " none" ;
98+ this . overlay . style . pointerEvents = ' none' ;
11099 }
111100
112101 /**
@@ -119,10 +108,10 @@ class ElementOverlay {
119108 */
120109 setBounds ( bounds ) {
121110 const { x, y, width, height } = bounds ;
122- this . overlay . style . left = x + "px" ;
123- this . overlay . style . top = y + "px" ;
124- this . overlay . style . width = width + "px" ;
125- this . overlay . style . height = height + "px" ;
111+ this . overlay . style . left = x + 'px' ;
112+ this . overlay . style . top = y + 'px' ;
113+ this . overlay . style . width = width + 'px' ;
114+ this . overlay . style . height = height + 'px' ;
126115 }
127116}
128117
@@ -159,12 +148,11 @@ class ElementPicker {
159148 this . active = true ;
160149 this . options = options ;
161150
162- document . addEventListener ( " mousemove" , this . handleMouseMove , true ) ;
163- document . addEventListener ( " click" , this . handleClick , true ) ;
151+ document . addEventListener ( ' mousemove' , this . handleMouseMove , true ) ;
152+ document . addEventListener ( ' click' , this . handleClick , true ) ;
164153
165154 const parentElement = options . parentElement || document . body ;
166- const useShadowDOM =
167- options . useShadowDOM !== undefined ? options . useShadowDOM : true ;
155+ const useShadowDOM = options . useShadowDOM !== undefined ? options . useShadowDOM : true ;
168156 this . overlay . addToDOM ( parentElement , useShadowDOM ) ;
169157 this . tick ( ) ;
170158
@@ -178,8 +166,8 @@ class ElementPicker {
178166 this . active = false ;
179167 this . options = undefined ;
180168
181- document . removeEventListener ( " mousemove" , this . handleMouseMove , true ) ;
182- document . removeEventListener ( " click" , this . handleClick , true ) ;
169+ document . removeEventListener ( ' mousemove' , this . handleMouseMove , true ) ;
170+ document . removeEventListener ( ' click' , this . handleClick , true ) ;
183171
184172 this . overlay . removeFromDOM ( ) ;
185173 this . target = undefined ;
@@ -206,12 +194,7 @@ class ElementPicker {
206194 */
207195 handleClick ( event ) {
208196 const clickedEl = document . elementFromPoint ( event . clientX , event . clientY ) ;
209- if (
210- this . options &&
211- this . options . elementFilter &&
212- clickedEl &&
213- ! this . options . elementFilter ( clickedEl )
214- ) {
197+ if ( this . options && this . options . elementFilter && clickedEl && ! this . options . elementFilter ( clickedEl ) ) {
215198 return ;
216199 }
217200
0 commit comments