jquery/css 中的 Ajax 加载器效果(即不是 ajaxload.info)

发布于 2024-09-30 13:00:10 字数 185 浏览 1 评论 0原文

有谁知道任何简单的库可以在不使用任何图像的情况下生成一些“加载”效果?

我问的原因是我时不时地使用ajaxload.info,但它只在纯色背景上效果很好。如果有背景渐变或图案,它看起来很糟糕...这也很烦人必须为每种纯色背景重新生成一个。

有什么可以工作的吗?

不必很复杂。只是一些动画效果来提供一些反馈..

Does any know any simple library that can generate some "loading" effects without using any images?

The reason why i'm asking is that i've been using ajaxload.info now and then, but it only really works well on a solid background color.. with a background gradient or pattern, it looks bad... it's also annoying to have to re-generate one for each solid background color.

Anything out there that could work?

Doesn't have to be complicated. Just a few animation effects to give some feedback..

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

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

发布评论

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

评论(1

只是一片海 2024-10-07 13:00:10

如果您对渐变有疑问,
只需选择一个限制在一个框中的加载器模板,例如:kit/bar/bar2/bar3..

如果您不想使用动画 gif,您可以使用 css3,但它无法在旧版浏览器上工作,< br>
你可以玩一些 jQuery 动画 - 比如动画文本“正在加载...”,例如:http://james.padolsey.com/javascript/fun-with-jquerys-animate/

[编辑]
以 james padolsey 的示例为例,下面是一个对象的运行演示,用于对给定 div 的文本进行动画处理以显示加载:
http://jsbin.com/ifiki3/edit

顺便说一句' - 我仍然会使用加载jif 用于此任务..

这是一个简单的示例 - 您可以根据需要整理代码,

这里是代码(但我只想转到 jsBin 链接):

function AnimateText(contSelector)
{

  this.cont = jQuery(contSelector);
  this.isRunning = false;
  this.animText = this.cont.text();
  this.duration = 1000;
  this.cont.hide();
}
AnimateText.prototype.Start = function()
{
  this.cont.show();
  this.isRunning = true;
  this.AnimateText();
}

AnimateText.prototype.Stop = function()
{
  this.cont.hide();
  this.isRunning = false;
}

AnimateText.prototype.AnimateText = function()
{
  if(this.isRunning === false)
  {
    return;
  }
  var animObj = this;
  var len = animObj.animText.length;
  jQuery({count:0}).animate({count:len}, {
      duration: animObj.duration,
    complete: function(){animObj.AnimateText();},
      step: function() {
          animObj.cont.text( animObj.animText.substring(0, Math.round(this.count)) );
      }
  });
}

$(document).ready(function()
{
  var animText = new AnimateText("#Loader");
  animText.Start();
  jQuery("#stopLoading").click(function(){animText.Stop()});
});

在 HTML 处:

  <div id="Loader">Loading...</div>
  <div id="stopLoading">click me to stop Loading</div>

if you have problems with the gradients,
just choose a loader template that is confined in a box like: kit/bar/bar2/bar3..

if you don't want to work with an animated gif you can use css3 but then it won't work on older browsers,
and you can play with some jQuery animations - like animating the text "Loading..." look here for example: http://james.padolsey.com/javascript/fun-with-jquerys-animate/

[edit]
taking james padolsey's example, here is a running demo of an object to animate a text of a given div to show loading:
http://jsbin.com/ifiki3/edit

BTW' - i would still use a loading jif for this task..

this is a quick example - you can tidy the code as you like

here is the code(but i would just go to the jsBin link):

function AnimateText(contSelector)
{

  this.cont = jQuery(contSelector);
  this.isRunning = false;
  this.animText = this.cont.text();
  this.duration = 1000;
  this.cont.hide();
}
AnimateText.prototype.Start = function()
{
  this.cont.show();
  this.isRunning = true;
  this.AnimateText();
}

AnimateText.prototype.Stop = function()
{
  this.cont.hide();
  this.isRunning = false;
}

AnimateText.prototype.AnimateText = function()
{
  if(this.isRunning === false)
  {
    return;
  }
  var animObj = this;
  var len = animObj.animText.length;
  jQuery({count:0}).animate({count:len}, {
      duration: animObj.duration,
    complete: function(){animObj.AnimateText();},
      step: function() {
          animObj.cont.text( animObj.animText.substring(0, Math.round(this.count)) );
      }
  });
}

$(document).ready(function()
{
  var animText = new AnimateText("#Loader");
  animText.Start();
  jQuery("#stopLoading").click(function(){animText.Stop()});
});

at the HTML:

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