diff --git a/apps/documenteditor/mobile/src/controller/Toolbar.jsx b/apps/documenteditor/mobile/src/controller/Toolbar.jsx index 4d29c4d74c..6eb2ac8380 100644 --- a/apps/documenteditor/mobile/src/controller/Toolbar.jsx +++ b/apps/documenteditor/mobile/src/controller/Toolbar.jsx @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useMemo, useState } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; import { Device } from '../../../../common/mobile/utils/device'; import { inject, observer } from 'mobx-react'; import { f7 } from 'framework7-react'; @@ -34,6 +34,7 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview', 'sto const storeDocumentInfo = props.storeDocumentInfo; const docExt = storeDocumentInfo.dataDoc ? storeDocumentInfo.dataDoc.fileType : ''; const docTitle = storeDocumentInfo.dataDoc ? storeDocumentInfo.dataDoc.title : ''; + const scrollOffsetRef = useRef(0); const getNavbarTotalHeight = useCallback(() => { const navbarBg = document.querySelector('.navbar-bg'); @@ -102,15 +103,17 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview', 'sto const isSearchbarEnabled = document.querySelector('.subnavbar .searchbar')?.classList.contains('searchbar-enabled'); if(!isSearchbarEnabled && navbarHeight) { - if(offset > 0) { + if(offset > scrollOffsetRef.current) { props.closeOptions('fab'); f7.navbar.hide('.main-navbar'); api.SetMobileTopOffset(undefined, 0); - } else if(offset <= 0) { + } else if(offset <= scrollOffsetRef.current) { props.openOptions('fab'); f7.navbar.show('.main-navbar'); api.SetMobileTopOffset(undefined, navbarHeight); } + + scrollOffsetRef.current = offset; } }