@@ -5,6 +5,7 @@ import Store from '../store';
55import locale from '../locale/locale' ;
66import sheetmanage from './sheetmanage' ;
77import tooltip from '../global/tooltip'
8+ import { $$ } from "../utils/util" ;
89
910let gridW = 0 ,
1011 gridH = 0 ;
@@ -100,13 +101,15 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) {
100101 </div>
101102 </div>
102103 </div>` ,
103- morediv = '<div id="luckysheet-icon-morebtn-div" class="luckysheet-wa-editor" style="position:absolute;top:' + ( Store . infobarHeight + Store . toolbarHeight + $ ( "#" + Store . container ) . offset ( ) . top + $ ( "body" ) . scrollTop ( ) ) + 'px; right:0px;z-index:1003;padding:5.5px;display:none;height:auto;white-space:initial;"></div>' ;
104+ // Add style left:$$('.luckysheet') left, when the worksheet does not fill the full screen
105+ morediv = '<div id="luckysheet-icon-morebtn-div" class="luckysheet-wa-editor" style="position:absolute;top:' + ( Store . infobarHeight + Store . toolbarHeight + $ ( "#" + Store . container ) . offset ( ) . top + $ ( "body" ) . scrollTop ( ) ) + 'px;right:0px;z-index:1003;padding:5.5px;visibility:hidden;height:auto;white-space:initial;"></div>' ;
104106
105107 if ( $ ( "#luckysheet-icon-morebtn-div" ) . length == 0 ) {
106108 $ ( "body" ) . append ( morediv ) ;
107109 }
108110
109- $ ( "#luckysheet-icon-morebtn-div" ) . hide ( ) ;
111+ // $("#luckysheet-icon-morebtn-div").hide();
112+ $$ ( "#luckysheet-icon-morebtn-div" ) . style . visibility = 'hidden' ;
110113 // $("#luckysheet-icon-morebtn-div > div").appendTo($("#luckysheet-wa-editor"));
111114
112115 $ ( "#luckysheet-icon-morebtn-div > div" ) . each ( function ( ) {
@@ -158,8 +161,31 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) {
158161
159162 $ ( "#luckysheet-wa-editor" ) . append ( morebtn ) ;
160163 $ ( "#luckysheet-icon-morebtn" ) . click ( function ( ) {
164+
165+ //When resize, change the width of the more button container in real time
166+ $$ ( '#luckysheet-icon-morebtn-div' ) . style . left = '' ; //reset
167+
168+ const containerLeft = $$ ( '#luckysheet' ) . getBoundingClientRect ( ) . left ;
169+ const morebtnLeft = $$ ( '#luckysheet-icon-morebtn-div' ) . getBoundingClientRect ( ) . left ; //get real left info
170+
171+ if ( morebtnLeft < containerLeft ) {
172+ $$ ( '#luckysheet-icon-morebtn-div' ) . style . left = containerLeft + 'px' ;
173+ }
174+
161175 let right = $ ( window ) . width ( ) - $ ( "#luckysheet-icon-morebtn" ) . offset ( ) . left - $ ( "#luckysheet-icon-morebtn" ) . width ( ) + $ ( "body" ) . scrollLeft ( ) ;
162- $ ( "#luckysheet-icon-morebtn-div" ) . toggle ( ) . css ( "right" , right < 0 ? 0 : right ) ;
176+
177+
178+ // $("#luckysheet-icon-morebtn-div").toggle().css("right", right < 0 ? 0 : right);
179+
180+ // use native js operation
181+ $$ ( '#luckysheet-icon-morebtn-div' ) . style . right = right < 0 ? 0 : right + 'px' ;
182+
183+ // change to visibility,morebtnLeft will get the actual value
184+ if ( $$ ( '#luckysheet-icon-morebtn-div' ) . style . visibility === 'hidden' ) {
185+ $$ ( '#luckysheet-icon-morebtn-div' ) . style . visibility = 'visible' ;
186+ } else {
187+ $$ ( '#luckysheet-icon-morebtn-div' ) . style . visibility = 'hidden' ;
188+ }
163189
164190 let $txt = $ ( this ) . find ( ".luckysheet-toolbar-menu-button-caption" ) ;
165191 if ( $txt . text ( ) . indexOf ( locale_toolbar . toolMore ) > - 1 ) {
@@ -558,6 +584,12 @@ export function menuToolBarWidth() {
558584 }
559585
560586 } ) ;
587+
588+ //If the container does not occupy the full screen, we need to subtract the left margin
589+ const containerLeft = $ ( '#' + Store . container ) . offset ( ) . left ;
590+ toobarWidths . forEach ( ( item , i ) => {
591+ toobarWidths [ i ] -= containerLeft ;
592+ } )
561593
562594}
563595
0 commit comments