在 Webkit 浏览器中使用 jQuery 动画后,缩放的透明 PNG 会失去抗锯齿功能
我有一个脚本,可以在地图上布置这些圆形图标,将鼠标悬停在它们上方,它们会弹出,出现文本等。图标相对于它们在地图上的位置(即 y- 上距 0 的距离)进行缩放。轴。我尝试通过CSS的宽度和高度属性以及通过html宽度和高度设置比例。 img 标签上的高度,但仍然存在相同的问题:
基本上,在休眠状态下,例如首次加载页面时,或者用户在选项卡之间滑动时,图像(反式 PNG)是抗锯齿的。然而,当调用hover()函数以及animate()函数时,图像突然变得锯齿状且可怕。我注意到这种行为在 Firefox 中不存在,但在 Safari 和 Chrome 中存在。我不知道这是否与 Webkit、jQuery 或者只是 javascript 本身有关,但也许有人可以透露一些信息,因为 google 没有结果。有什么想法吗? :)
另请注意,左下角和右下角的图标在所附的两个屏幕截图中看起来都很好 - 它们是未缩放的!
非常感谢:) 马特
I have a script that lays out these circular icons on the map, you hover over them, they spring up, text appears, etc. The icons are scaled relative to their position on the map, ie, the distance from 0 on the y-axis. I've tried to set the scale through CSS's width and height attributes and through the html width & heights on the img tag and still have the same problem:
Basically, in their dormant state, such as when the page is first loaded, or the user flicks between tabs, the images (trans' PNGs) are anti-aliased. However, when the hover() function, and thus the animate() function, is invoked, the images suddenly become jagged and horrid. I've noticed that this behaviour doesn't exist in firefox but does in safari and chrome. I don't know whether this is to do with Webkit, jQuery or just javascript itself but maybe someone could shine some light as google resulted in nothing. Any thoughts? :)
Please also note that the bottom left and bottom right icons look fine in both attached screenshots- they're unscaled ones!
Thanks a lot :)
Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只能猜测这一点,但我的假设是 gecko 和 webkit 对图像使用不同的缩放算法。因此它与 javascript、jquery 或 png 完全无关。
事实上,即使在 webkit 屏幕截图中,图像仍然具有抗锯齿边缘。 (当你放大时你会看到)
边框被弄乱了,这通常是糟糕的缩放算法的结果。
请尝试以下操作来确认此假设:
并比较两个浏览器中的结果。你应该看到同样的问题。
可能的解决方案:
i can only guess on this, but my assumption is that gecko and webkit use different scaling algorithms for images. thus it has nothing to do with javascript, jquery or png at all.
in fact, the image still has antialiased edges even in the webkit screenshot. (you see that when you zoom in)
the border is just messed up which is usually the result of a bad scaling algorithm.
try the following to confirm this assumption:
and compare the result in the two browsers. you should see the same problem.
possible solutions: