如何在 XUL 中为 Firefox 附加组件制作面板动画

发布于 2024-09-19 15:48:57 字数 436 浏览 13 评论 0原文

我为我工作的公司编写了一个不错的小型 Firefox 插件,作为 IT 票务系统。它的作用是通知经理新的工单或通知用户工单的更改。

我开始在 Windows 上使用 Firefox 的内置通知程序:

varalertsService = Components.classes["@mozilla.org/alerts-service;1"].getService(Components.interfaces.nsIAertsService);

这非常有效。然而,该服务的问题在于,您实际上无法控制其速度、时间、样式或内容呈现方式。我决定改用面板,它效果很好,可以在我想要的地方显示我想要的内容。

然而,我很想让它变得更加明显,就像通知一样,通过动画面板向上移动并从透明变为几乎固体。有谁有方法可以做到这一点?我发现了一些 JavaScript 代码片段,但没有发现任何真正可以正常工作的东西。

I have written a nice little Firefox Add-On for the company I work for as an IT Ticket System. What it does is notifies managers of new tickets or notifies users of changes to their tickets.

I started out using the built in notifer for Firefox on Windows with:

var alertsService = Components.classes["@mozilla.org/alerts-service;1"].getService(Components.interfaces.nsIAlertsService);

This worked really well. However, the problem with that service is that you don't really have any control over it's speed, timing, styling, or the way content is presented. I decided to switch to using a panel, which works great and display what I want, where I want.

However, I would quite like to make it a little more obvious in the same way the notifications are by animating the panel to move up and go from transparent to almost solid. Does anyone have methods by which to do that? I've found some little JavaScript code snippits, but not found anything that really works properly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无妨# 2024-09-26 15:48:57

没有任何内置方法来执行动画,因此您需要滚动自己的计时器并更新面板的位置。

您可以尝试调用 panel.moveTo 方法来重新定位。

https://developer.mozilla.org/en/XUL/panel#m- moveTo

您还可以使面板成为一个单独的窗口并更新窗口的顶部/左侧。警报服务会执行“滑动”类型的动画,在其中调整窗口向上展开。你可以从这里得到它。

http://mxr.mozilla。 org/mozilla1.9.2/source/toolkit/components/alerts/resources/content/alert.js

There aren't any built in methods to do animations, so you'll need to roll your own timer and update the position of the panel.

You can try calling panel.moveTo method for repositioning.

https://developer.mozilla.org/en/XUL/panel#m-moveTo

You could also make the panel a seperate window and update the window's top/left. The alert service does a "swipe" type animation where they tweak the window unrolls upwards. You can get that from here.

http://mxr.mozilla.org/mozilla1.9.2/source/toolkit/components/alerts/resources/content/alert.js

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文