实现iziModal弹窗移动的功能
来源:互联网 发布:淘宝排名突然下降 编辑:程序博客网 时间:2024/06/02 19:42
有下载链接
<!DOCTYPE html><html lang="zh"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>iziModa</title><link rel="stylesheet" type="text/css" href="css/iziModal.css"><script src="js/jquery-2.1.1.min.js"></script><script src="js/iziModal.min.js" type="text/javascript"></script><script src="js/dragcommon.js" type="text/javascript"></script></head><body><div id="modal-msg" class="iziModal" usemap="#planetmap" alt="Planets"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore voluptate aut dignissimos iusto, perferendis corrupti deserunt. Cum, distinctio atque iusto, voluptatum illum fugiat asperiores dignissimos harum incidunt nam! Ad, dolorum.</p> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Explicabo error aperiam voluptates enim quo unde officiis vero aliquid iste omnis odit nihil eaque quasi deserunt nesciunt, architecto, illo tenetur dolores!</p> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis, modi voluptate voluptates pariatur quos distinctio perspiciatis, vitae nihil consectetur, ipsam a magnam omnis sequi necessitatibus. Quisquam nesciunt ullam iste optio!</p> </div><script type="text/javascript">$(function() { $("#modal-msg").iziModal({ title: "Welcome to the iziModal", subtitle: "Simple, complete and lightweight modal plugin with jquery.", iconClass: 'icon-announcement', width: 700, padding: 20 }); $('#modal-msg').iziModal('open'); drag();});</script></body></html>
//执行modal-data弹窗拖拽的方法function drag() {$(".iziModal-header").attr("id", "modalmsg"); $(document).on("closing","#modal-msg",function(e){ //删除打开的弹窗 $(".iziModal").remove(); }); //加载完modal执行删除遮罩层 $(".fadeIn").remove();// 清除固定的位置$("#modal-msg").css("margin-left", "");$("#modal-msg").css("margin-top", "");// 设定位置$(".iziModal").css("left", "35%");$(".iziModal").css("top", "39%");// 窗体的位置是通过调整iziModal的css样式实现的$(".iziModal-header").css("cursor", "move");// 鼠标拖拽的方法var posX;var posY;coordinate=document.getElementById("modalmsg");coordinates = document.getElementById("modal-msg");coordinate.onmousedown = function(e) {posX = event.x - coordinates.offsetLeft; // 获得横坐标xposY = event.y - coordinates.offsetTop; // 获得纵坐标ydocument.onmousemove = mousemove; // 调用函数,只要一直按着按钮就能一直调用};document.onmouseup = function() {document.onmousemove = null; // 鼠标举起,停止};function mousemove(ev) {if (ev == null)ev = window.event; // IEvar a = coordinates.style.left = (ev.clientX - posX) + "px";var b = coordinates.style.top = (ev.clientY - posY) + "px";}//主动加载触摸方法handtouch();}//触摸操作function handtouch() {// 获取节点//监听标题的id点击事件,移动其他idvar blocks = document.getElementById("modalmsg");var block = document.getElementById("modal-msg");var oW, oH;// 绑定touchstart事件blocks.addEventListener("touchstart", function(e) {var touches = e.touches[0];oW = touches.clientX - block.offsetLeft;oH = touches.clientY - block.offsetTop;//阻止页面的滑动默认事件document.addEventListener("touchmove", defaultEvent, false);}, false)blocks.addEventListener("touchmove", function(e) {var touches = e.touches[0];var oLeft = touches.clientX - oW;var oTop = touches.clientY - oH;if(oLeft < 0) {oLeft = 0;} else if(oLeft > document.documentElement.clientWidth - block.offsetWidth) {oLeft = (document.documentElement.clientWidth - block.offsetWidth);}block.style.left = oLeft + "px";block.style.top = oTop + "px";}, false);blocks.addEventListener("touchend", function() {document.removeEventListener("touchmove", defaultEvent, false);}, false);function defaultEvent(e) {}}
阅读全文
0 0
- 实现iziModal弹窗移动的功能
- 实现窗体的移动功能
- 实现控件的移动功能
- 基于Unity3D的移动端摇一摇功能的实现
- 移动定位的业务功能与实现原理
- C#中用鼠标移动页面功能的实现
- C#中用鼠标移动页面功能的实现
- FxCAD实验二 实现对象的移动功能
- C#之移动无标题栏窗体功能的实现!...
- MovieClip实现拖拽等移动位置的功能
- sqlserver实现对TreeView节点上下移动的排序功能
- VC实现具有回车移动焦点功能的编辑框
- Jquery实现鼠标移动,放大图片的功能
- Bootstrap图标实现移动端的星星评分功能
- 移动app与CRM签名功能的实现
- jQuery移动端拆红包功能的实现
- 移动产品热更新的功能指标和实现架构
- iziModal使用过程遇到
- Scala 中的文件操作
- H5面试——HTTP状态码
- leetcode--Sudoku Solver
- Learning to Track at 100 FPS with Deep Regression Networks 论文笔记
- CSS选择器
- 实现iziModal弹窗移动的功能
- HDU 3729 I'm Telling the Truth(二分图匹配+匈牙利算法+变形)
- spring-boot oauth2
- MySQL 线程池内幕
- 简单实现Ajax异步上传文件
- leetcode--Count and Say
- re.findall
- 牛客刷题知识点总结
- Pthread_mutex_t锁