Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

fix: improve fullscreen mode #217

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

OneGIl
Copy link
Contributor

@OneGIl OneGIl commented Aug 24, 2023

  • invalid "Exit Fullscreen" button

点击"Fullscreen"按钮后,popper隐藏后的5秒钟后再打开Popper,理应是"Exit Fullscreen"的按钮,结果被初始化为"Fullscreen",所以在frame-state里保存了viewMode这个状态。

  • disabled resize in non "default" view mode

在viewMode是非"default"的情况下,panel是可以继续调整大小的(虽然看起来没有变化),一旦调整后恢复为"default",则panel会变成错误的大小

  • set correct anchor position in fullscreen

在全屏状态下,使用快捷键隐藏panel后,anchor移动到屏幕左下角,且无法改变位置。

  • edge case
Kapture.2023-08-30.at.12.57.10.mp4

@OneGIl OneGIl changed the title Fix/fullsreen mode fix: improve fullscreen mode Aug 24, 2023

function toggleViewMode(mode: ViewMode) {
const newMode = mode ?? perViewMode
setTimeout(() => {
Copy link
Contributor Author

@OneGIl OneGIl Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里使用setTimeout是因为在eyedropper里close方法里会同时修改client和node中的frameState,这会赋给viewMode错误的值。暂时没找到合适的解决方法。所以在这里用了setTimeout。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以针对 eyeDropper 这种 viewMode 是 xs 的单独写一个判断逻辑

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢建议,这部分我会再考虑一下~

@alexzhang1030
Copy link
Collaborator

Hey @OneGIl , can you get my comments?

Like this:

image

@OneGIl
Copy link
Contributor Author

OneGIl commented Sep 11, 2023

Hi~ @alexzhang1030
Is it a problem with my operation? I really can't see your review comments.

image

@alexzhang1030
Copy link
Collaborator

@webfansplz Do you have any idea? And can you see my review comments?

Copy link
Collaborator

@alexzhang1030 alexzhang1030 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test comment?

@@ -118,49 +116,49 @@ const viewModeClass = computed(() => {
>
<!-- Handlers -->
<div
v-show="state.position !== 'top'"
v-show="state.position !== 'top' && props.viewMode === 'default'"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracting props.viewMode === 'default' to a computed variable called ableToResize or something, which will be more maintainable.

Copy link
Contributor Author

@OneGIl OneGIl Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexzhang1030 got it~

state.value.viewMode = value
},
})
let perViewMode = viewMode.value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preViewMode? Looks like a typo here.


function toggleViewMode(mode: ViewMode) {
const newMode = mode ?? perViewMode
setTimeout(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以针对 eyeDropper 这种 viewMode 是 xs 的单独写一个判断逻辑

@OneGIl OneGIl marked this pull request as draft September 11, 2023 09:28
@OneGIl OneGIl marked this pull request as ready for review September 11, 2023 17:09
router.replace(frameState.route.value)
router.replace(frameState.route.value).then(() => {
client.value?.panel?.toggleViewMode()
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里无法通过同步的方式调用router.replace和toggleViewMode,否则就会设置成错误值。 也尝试在toggleViewMode方法中解决,可惜没找到好的方法。

"可能"的原因:

  • 梳理了代码后发现在client中的路由守卫会设置state的route值,而toggleViewMode方法也会改变state里的viewMode值。只不过这两个改变值的方式不同。在useObjectStorage中,前者通过useWindowEventListener方式监听localStorage并用新值覆盖hook中的state,而后者是用watch监听state并用新值覆盖localStorage。由于路由是异步的,处理速度上会比toggleViewMode慢一点(?),这将在设置route值的时候拿到了老的viewMode,最终赋值错误。
  • 但上面的原因好像不能解释为什么用setTimeout就可以解决赋值错误的问题。

所以,我有一个不成熟的想法,不知道是否可行?就是在client端只通过client实例(useDevToolsClient)来获取state状态,以及修改state。而不是在client端使用useLocalStorage来获取state。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants