您的位置:首页 > 其它

loading加载中效果

2016-01-11 15:19 447 查看
(function(){
try{
var ui={
loading:{
addCssStyle:function(text) {
var head = document.getElementsByTagName('head')[0];
var node = document.createElement('style');
node.type = 'text/css';
head.appendChild(node);
node.innerHTML = text;
return node;
},
init:function(parent){
var html =' <div class="spinner">';
for(var i=0;i<12;i++){
html = html+ '<div class="bar'+(i+1)+'"></div>';
}
html = html+ '</div>';
if($(parent).find(".spinner").length == 0)
{
$(parent).append(html);
if($("#spinner").length == 0){
var css = ".spinner{width:30px;display:inline-block;position:relative}.spinner div{width:2px;height:4px;background-color:grey;position:absolute;opacity:0;-webkit-border-radius:60%;-webkit-animation:fade 1s linear infinite;top:-8px;left:10px}@-webkit-keyframes fade{from{opacity:1}to{opacity:.25}}";
for(var i=0;i<12;i++){
css = css + ".spinner div.bar"+(i+1)+"{-webkit-transform:rotate("+i*30+"deg) translate(0,-142%);-webkit-animation-delay:"+((0.0837*i-1))+"s}";
}
console.log(css);
this.addCssStyle(css);
}
}
},
show:function(parent){
this.init(parent);
$(parent).find(".spinner").show();
},
hide:function(parent){
$(parent).find(".spinner").hide();
}
}
};
window.Rui = ui;
}catch(e){
console.log(e);
}
})();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: