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

🐛[BUG]a标签在sketch插件中提供的web中调用getBoundingClientRect方法返回值问题 #47

Open
LiFaNSuperMan opened this issue Oct 28, 2020 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@LiFaNSuperMan
Copy link

LiFaNSuperMan commented Oct 28, 2020

🐛 bug 描述

a标签在sketch插件中提供的web中执行
const bcr = node.getBoundingClientRect();
这段代码的时候,不能返回准确的自身rect值,返回的是父节点的值,有什么能替换的方法么

modify

上面描述的不准确,返回的还是自身的值 但是因为换行返回的rect被撑开了 在设置textLayer的x和y的时候就会出现不准确的情况
test

如图得到的rect就是红色的框

📷 复现步骤

在转换如下节点时复现的问题

<span>
阅读
<a >xxxx协议</a>
</span>
@LiFaNSuperMan
Copy link
Author

我追了下代码,看起来原因是因为这个标签的文字换行了,导致获取rect的时候被撑开了,然后转换的layer的frame就变成了换行后整体的rect,不换行的话问题就不会出现,这个问题似乎不是很好解决

@arvinxx
Copy link
Collaborator

arvinxx commented Oct 28, 2020

把你的 demo 拿过来了下:https://codesandbox.io/s/a-huanxingwenti-6mcbh

复制出来的结果看上去没有问题?
image

@LiFaNSuperMan
Copy link
Author

后面的标签换行了就会出现我说的问题了,应该也不限制a标签,只要文字换行了这个问题应该都会有
test

@arvinxx
Copy link
Collaborator

arvinxx commented Nov 11, 2020

这个问题目前来看有点难办,得对文本解析的方式重新做一次解析,我研究看看

@LiFaNSuperMan
Copy link
Author

辛苦

@arvinxx arvinxx mentioned this issue May 8, 2021
6 tasks
@arvinxx
Copy link
Collaborator

arvinxx commented Feb 3, 2023

sketch 使用的模型和 浏览器的模型不太一致,解析难度很大。暂时不考虑支持了

@arvinxx arvinxx added the help wanted Extra attention is needed label Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants