加载等待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 ...
随机推荐
- Android本地存储方案 SharedPreferences
原文地址:http://www.yanwushu.com/post/43.html 存储位置 SharedPreferences数据保存在: /data /data/<package_name& ...
- 新疆大学(新大)OJ xju 1009: 一带一路 prim求最短路径+O(n)素数筛选
1009: 一带一路 时间限制: 1 Sec 内存限制: 128 MB 题目描述 一带一路是去去年习大大提出来的建设“新丝绸之路经济带”和“21世纪海上丝绸之路”的战略构想.其中就包括我们新疆乌鲁木 ...
- Glide中的回调:targets
Glide隐藏了一大推复杂的在后台的场景,Glide做了所有的网络请求和处理在后台线程中,准备好了切回到ui线程后更新ImageView. 假设ImageView不再是图像的最后一步.我们只要Bitm ...
- js实现数组的去重
function filterRepat(arr){ if(Array.isArray(arr) && arr.length){ var arr = arr.filter(functi ...
- SpringBoot学习笔记(12)----SpringBoot实现多个 账号轮询发送邮件
首先,引入发送邮件的依赖,由于freemarker自定义模板,所以也需要把freemarker的依赖引入 pom.xml文件 <dependency> <groupId>org ...
- 总结Ajax的一些细节
Ajax的总结 主要从Ajax是什么?可以用来干什么?基本要素,优缺点,执行过程,跨域的解决方案等几方面来解释. Ajax是什么? Ajax主要用来实现客户端与服务器端的异步通信效果,实现页面的局部刷 ...
- 简洁的MVC思想框架——Nancy(Post操作与外部引用css和JS)
之前介绍了关于Nancy配置与Get基础操作,以下来介绍有关Nancy的Post操作. 第一步,设计主界面,以登录界面为例:Login.cshtml 路径为: 设计好页面后,在之前的modules类中 ...
- json转换方法
import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.ut ...
- jQuery第一课 加载页面弹出一个对话框
<script type="text/javascript"> $(document).ready(function(){ alert("欢迎收看:" ...
- linux下安装jdk跟tomcat
文章参考 https://www.cnblogs.com/geekdc/p/5607100.html Linux服务器安装jdk+tomcat https://baijiahao.baidu ...