如何创建动画加载指示器 Spotify 应用程序
如何使用设计资源文件夹中提供的loading_indicator.png 使其像ajax 加载器一样工作?
How I do use the loading_indicator.png provided in the design resources folder to make it act like an ajax loader?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我在启动应用程序时显示加载指示器的方式,该指示器取自“主页”应用程序(新增功能)。在你的index.html 中:
在你的app.css 中:
adam.css 是深色Spotify 主题,eve.css 是浅色主题。然后,当您的应用程序加载完成后,只需删除该元素即可。您可以使用 spotify dom.js 中的 dom 方法来完成此操作。在你的app.js中:
我不知道dom.js是否会出现在官方API中。否则,您可以通过任何其他方式删除它(标准 dom 方法、您正在使用的其他 js 库等):
请注意,上面的示例不一定使用loading_indicator.png,而是使用 adam.css 和 eve 使用的任何图像.css 主题。
如果您不想将加载程序用作应用程序内的普通 Ajax 加载指示器,则适用 Web 应用程序的所有正常规则。启动ajax调用时显示加载器,将其隐藏在completed-callback中,使用css定位。
This is how I display a loading indicator when starting my app, taken from the 'home' application (What's New). In your index.html:
In you app.css:
adam.css being the dark Spotify theme and eve.css the light. Then, when your application is finished loading, just remove the element. You can do it with the dom methods in the spotify dom.js. In your app.js:
I don't know if the dom.js will be in the official API or not. Otherwise you can remove it any other way (standard dom methods, other js libraries you're using, etc):
Note that the above example does not necessarily use the loading_indicator.png but whatever images that are used by the adam.css and eve.css themes.
If you wan't to use the loader as a normal ajax loading indicator inside your app, then all the normal rules of web apps apply. Display loader when initiating ajax call, hide it in completed-callback, position it with css.
我意识到这是一个老话题,但是使用 1.X API,有一种更简单的方法可以通过 使用 Throbber 类,它允许您通过 JS 相当简单地实例化和隐藏。
只需确保在 JS 的开头包含 Throbber 类即可:
I realize this is an old topic, but with the 1.X API there is an easier way to do this by using the Throbber class which allows you to instantiate and hide fairly simply via JS.
Just make sure to include the Throbber class at the beginning of your JS: