@@ -259,11 +259,11 @@ function initButton(sfHost, inInspector) {
259259 closePopup ( ) ;
260260 }
261261 } ) ;
262+ let popupArrowOrientation = localStorage . getItem ( "popupArrowOrientation" ) ;
262263 let popupWrapper = document . createElement ( "div" ) ;
263264 let popupEl = document . createElement ( "iframe" ) ;
264265 popupEl . classList . add ( "insext-popup-iframe" ) ;
265- function onbuttonmove ( event ) {
266- let popupArrowOrientation ;
266+ function onButtonMove ( event ) {
267267 let popupArrowPosition ;
268268 // if above the diagonal
269269 if ( event . clientY > ( event . clientX / document . documentElement . clientWidth ) * document . documentElement . clientHeight ) {
@@ -278,18 +278,18 @@ function initButton(sfHost, inInspector) {
278278 updateButtonCSSPropertiesIfNeeded ( rootEl , btn , popupWrapper , popupArrowOrientation , popupArrowPosition ) ;
279279
280280 }
281- function endmove ( ) {
282- window . removeEventListener ( "mousemove" , onbuttonmove ) ;
283- window . removeEventListener ( "mouseup" , endmove ) ;
281+ function endMove ( ) {
282+ window . removeEventListener ( "mousemove" , onButtonMove ) ;
283+ window . removeEventListener ( "mouseup" , endMove ) ;
284284 }
285285 btn . addEventListener ( "mousedown" , ( ) => {
286- window . addEventListener ( "mousemove" , onbuttonmove ) ;
287- window . addEventListener ( "mouseup" , endmove ) ;
286+ window . addEventListener ( "mousemove" , onButtonMove ) ;
287+ window . addEventListener ( "mouseup" , endMove ) ;
288288 } ) ;
289289
290290 let popupSrc = chrome . runtime . getURL ( "popup.html" ) ;
291291 popupWrapper . className = "insext-popup" ;
292- popupWrapper . classList . add ( localStorage . getItem ( " popupArrowOrientation" ) == "horizontal" ? "insext-popup-horizontal" : "insext-popup-vertical" ) ;
292+ popupWrapper . classList . add ( popupArrowOrientation == "horizontal" ? "insext-popup-horizontal" : "insext-popup-vertical" ) ;
293293
294294 popupEl . src = popupSrc ;
295295 addEventListener ( "message" , e => {
@@ -373,12 +373,22 @@ function initButton(sfHost, inInspector) {
373373 }
374374 let popupWidth = resizeWidth - ( event . clientX - resizeX ) ;
375375 let boundingClientRect = popupEl . getBoundingClientRect ( ) ;
376- if ( popupHeight > window . innerHeight - boundingClientRect . top - 50 ) {
377- popupHeight = window . innerHeight - boundingClientRect . top - 50 ;
378- }
379- if ( popupWidth > window . innerWidth - 50 ) {
380- popupWidth = window . innerWidth - 50 ;
376+ if ( popupArrowOrientation == "vertical" ) {
377+ if ( popupHeight > window . innerHeight - boundingClientRect . top - 50 ) {
378+ popupHeight = window . innerHeight - boundingClientRect . top - 50 ;
379+ }
380+ if ( popupWidth > window . innerWidth - 50 ) {
381+ popupWidth = window . innerWidth - 50 ;
382+ }
383+ } else if ( popupArrowOrientation == "horizontal" ) {
384+ if ( popupHeight > window . innerHeight - 50 ) {
385+ popupHeight = window . innerHeight - 50 ;
386+ }
387+ if ( popupWidth > window . innerWidth - boundingClientRect . left - 50 ) {
388+ popupWidth = window . innerWidth - boundingClientRect . left - 50 ;
389+ }
381390 }
391+
382392 if ( popupHeight < 0 ) {
383393 popupHeight = 50 ;
384394 }
0 commit comments