Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤔 为啥 scroller plugin, 没有 抹平 translate 差异 #3435

Closed
0jinxing opened this issue Mar 28, 2023 · 9 comments
Closed

🤔 为啥 scroller plugin, 没有 抹平 translate 差异 #3435

0jinxing opened this issue Mar 28, 2023 · 9 comments
Labels
type: discussion 讨论 Usage questions, guidance, and other discussions

Comments

@0jinxing
Copy link
Contributor

Describe the feature you'd like to request

需求 原来用 x6 做了一个简单的画布协同(依赖了 画布的 translate)
现在想修改下 画布 滚动逻辑,发现 scroller plugin 不仅没有 抹平 translate
我还没甚至找到 trigger 画布滚动的事件(我需要自己去 container addEventListener 🤔)
这样做是出于什么考虑吗?

还有一个疑问是 scroller 是一个 plugin
但是

const scroller = this.getPlugin<any>('scroller')

为什么感觉这么耦合🤔

Describe the solution you'd like

可以抹平 scroller 和 translate

Describe alternatives you've considered

可以抹平 scroller 和 translate

Your Example Website or App

No response

Screenshots or Videos

No response

@NewByVector
Copy link
Contributor

translate 是偏移画布内容视口,也就是 x6-graph-svg-viewport。它在 scroller 和非 scroller 下面表现是一致的。如果想调整滚动位置,可以使用 graph.setScrollbarPosition API。

@NewByVector
Copy link
Contributor

X6 代码现在有些地方确实和 plugin 存在耦合,当时的思考是:怎么让用户无感升级,也就是使用 api 不变,达到和 1.x 一样的效果,比如上面的 resize 方法,能做到在 scroller 开启和关闭下实现逻辑不一致。所以做了一些妥协。我新开了一个 issue,尽快治理这个问题,将核心渲染和插件解耦开来。

@NewByVector NewByVector added the type: discussion 讨论 Usage questions, guidance, and other discussions label Mar 29, 2023
@jefferyol
Copy link

我也遇到了相同的问题,使用scroll插件之后,画布的translate事件就失效了 ,以及使用scroll插件滚动后画布的translate值没有更新@NewByVector

@0jinxing
Copy link
Contributor Author

0jinxing commented Nov 7, 2023

我也遇到了相同的问题,使用scroll插件之后,画布的translate事件就失效了 ,以及使用scroll插件滚动后画布的translate值没有更新@NewByVector

我现在是自己加了个判断 if hasScroller xxx else yyy

@jefferyol
Copy link

我尝试在container和外层的x6-graph-scroller上去监听滚动事件,都没有生效,可以请教下是如何实现的吗,感谢。 @0jinxing

@jefferyol
Copy link

translate值倒是可以用滚动条偏移量去自己算

@0jinxing
Copy link
Contributor Author

我尝试在container和外层的x6-graph-scroller上去监听滚动事件,都没有生效,可以请教下是如何实现的吗,感谢。 @0jinxing

const scroller = graph.getPlugin<Scroller>('scroller');
scroller?.container.addEventListener('scroll', handleScroll);

可以这么搞

@jefferyol
Copy link

好的,我试下,感谢

@x6-bot
Copy link
Contributor

x6-bot bot commented Nov 13, 2024

This thread has been automatically locked because it has not had recent activity.

Please open a new issue for related bugs and link to relevant comments in this thread.

@x6-bot x6-bot bot locked as resolved and limited conversation to collaborators Nov 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: discussion 讨论 Usage questions, guidance, and other discussions
Projects
None yet
Development

No branches or pull requests

3 participants