加载等待loading
自己写的一个小插件,还有很多需要完善。。。
(function ($) {
$.fn.StartLoading = function (option) {
var defaultVal = {
loadgif: 'image/loading.gif',
backcolor: 'white',
picheight: 50,
picwidth: 50,
fullshowpic: false,//图片是否设置透明度
opacity: 0.5,
timeout: 3000
}
var result = $.extend({}, defaultVal, option);
var $obj = $(this);//选择器的Jquery对象
var iswndordoc = false;
if ($(this).get(0) == document || $(this).get(0) == window || $(this).get(0) == document.body) {
iswndordoc = true;
$obj = $(document.body);
}
//获取对象属性
var constClone = {
constwidth: $obj.width(),
constheight: $obj.height(),
constleft: iswndordoc == true ? 0 : $obj.offset().left,
consttop: iswndordoc == true ? 0 : $obj.offset().top
}
if (iswndordoc) {
var $clonebottom = $("<div></div>");
} else {
if ($(this)[0].tagName != "div") {
var $objTemp = $("<div id=\"_temp_div\" style=\"width:" + constClone.constwidth + "; height:" + constClone.constheight + "; left:" + constClone.constleft + "; top:" + constClone.consttop + "\"></div>");
$($obj.parent().get(0)).append($objTemp);
$obj = $objTemp;
}
//生成最底层DIV
var $clonebottom = $obj.clone().removeAttr("id").removeAttr("class").removeAttr("name");
}
//设置最底层DIV属性
$clonebottom.removeClass().removeAttr("style").empty().css({
"position": "absolute",
"left": constClone.constleft,
"top": constClone.consttop,
"z_index": "10000",
"width": constClone.constwidth,
"height": constClone.constheight,
"background-color": "transparent"
});
var $cloneTop = $clonebottom.clone().css({ "z_index": "9999", "background-color": "" + result.backcolor + "", "position": "" });
$clonebottom.append($cloneTop);
$clonebottom.append("<img id=\"_loading_plugin\" src=\"" + result.loadgif + "\" style=\"position:absolute;z_index: 9999\"/>");
if (iswndordoc) {
$obj.append($clonebottom);
} else {
$($obj.parent().get(0)).append($clonebottom);
}
var $imgloading = $("#_loading_plugin");
$imgloading.css({ "width": "" + result.picwidth + "px", "height": "" + result.picheight + "px" });
$imgloading.css({ "left": (constClone.constwidth - $imgloading.width()) / 2, "top": (constClone.constheight - $imgloading.height()) / 2 });
if (result.fullshowpic)
$clonebottom.css("opacity", "" + result.opacity + "");
else
$cloneTop.css("opacity", "" + result.opacity + "");
var hand = setTimeout(function () {
$clonebottom.fadeOut("slow", function () {
$(this).remove();
clearTimeout(hand);
});
}, result.timeout)
return $clonebottom;
}
$.fn.StopLoading = function () {
var $globalthis = $(this);
$globalthis.remove()
}
})(jQuery)
用法: 开始显示 var $load = $(window).StartLoading({ timeout: 1000000, fullshowpic: true }); 结束显示: $load.StopLoading();
加载等待loading的更多相关文章
- [Swift通天遁地]一、超级工具-(11)使用EZLoadingActivity制作Loading加载等待动画
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- vue-element-admin 全局loading加载等待
最近遇到需求: 全局加载loading,所有接口都要可以手动控制是否展示加载等待的功能 当拿到这个需求的时候我是拒绝的,因为我以及局部写好了0.0,这是要大改呀....,没办法老板的要求,只能硬着头皮 ...
- 《动手实现一个网页加载进度loading》
loading随处可见,比如一个app经常会有下拉刷新,上拉加载的功能,在刷新和加载的过程中为了让用户感知到 load 的过程,我们会使用一些过渡动画来表达.最常见的比如"转圈圈" ...
- IOS开发UI篇之──自定义加载等待框(MBProgressHUD)
本文转载至 http://blog.csdn.net/xunyn/article/details/8064984 原文地址http://www.189works.com/article-89289 ...
- WPF加载等待动画
原文:WPF加载等待动画 原文地址:https://www.codeproject.com/Articles/57984/WPF-Loading-Wait-Adorner 界面遮罩 <UserC ...
- fakeLoader页面加载前loading演示8种效果
提高用户体验的插件fakeLoader页面加载前loading演示8种效果 在线预览 下载地址 示例代码 <div id="main"> <div class=& ...
- C#窗体的加载等待(BackgroundWorker控件)实现
窗体拉一个Button按钮和一个加载等待显示的label, label默认隐藏,点击按钮时显示这个label,加载完再隐藏 1.工具箱拉BackgroundWorker控件到窗体 2.backgrou ...
- cocos2d-x游戏开发(十五)游戏加载动画loading界面
个人原创,欢迎转载:http://blog.csdn.net/dawn_moon/article/details/11478885 这个资源加载的loading界面demo是在玩客网做逆转三国的时候随 ...
- ajax加载菊花loading效果
Ajax异步请求的时候,一般都会利用一个动态的gif小图片来制作一个Ajax Loading,以便增加用户体验. 这里我们可以使用Spin.js,该js脚本压缩后5k,可以不用任何图片,任何外部CSS ...
随机推荐
- JAVA设计模式之【职责链模式】
职责链模式 专门处理请求链式传递的模式 角色 Handler抽象处理者 ConcreteHandler具体处理者 在职责链模式中,很多对象由每一个对象对其下家的引用而连接成一条链,请求在这条链上传递, ...
- xBIM 基础01 简介
系列目录 [已更新最新开发文章,点击查看详细] 一.xBIM 简介 BIM(Building Information Modelling)建筑信息模型,xBIM(eXtensible Buil ...
- 修改echarts环形图的牵引线及文字位置
修改echarts环形图的牵引线及文字位置,下面代码及效果不仅如此,也包含了其它的效果哦.有问题可以留言. 根据echarts官方示例修改效果: 官方示例图: 修改效果图: 直接上代码:其它不多说. ...
- KMP算法中求next数组的实质
在串匹配模式中,KMP算法较蛮力法是高效的算法,我觉得其中最重要的一点就是求next数组: 看了很多资料才弄明白求next数组是怎么求的,我发现我的忘性真的比记性大很多,每次看到KMP算法求next数 ...
- 阿里巴巴战略投资印度最大支付平台Paytm
腾讯科技讯 9月29日,据路透社报道,阿里巴巴和印度最大移动支付和商务平台Paytm今天发布联合声明,宣布阿里巴巴集团及其旗下金融子公司蚂蚁金服将向Paytm注入新资金.阿里称这是一项“战略性的”投资 ...
- js中深拷贝代码实现
function copy(original,o){ if(typeof original != 'object') return original; var o = o || (Array.isAr ...
- hdu 2037 - 典型贪心*
题目链接 给一堆电视节目的起止时间,问最多能完整收看几个节目 --------------------------------------------------------------------- ...
- hdu 1257/1800 - 贪心,dp
1257题目链接 一个序列划分子序列,每个子序列都是非增序列,问最少分成几个子序列 1800题目链接 一堆数分组,每组内数据严格递减,问最少分几组 -------------------------- ...
- 使用maven插件dockerfile-maven-plugin生成Docker镜像并推送到镜像仓库
1.引入maven插件 <build> <plugins> <plugin> <groupId>com.spotify</groupId> ...
- 洛谷P2766 最长不下降子序列问题 网络流_DP
Code: #include<cstdio> #include<iostream> #include<vector> #include<algorithm&g ...