HTML5为所有HTML元素规定了一个draggable属性,表示元素是否可以拖动,图像和链接的draggable属性自动被设置成了true,而其他元素这个属性的默认值都是false。
[注意] Angular下必须设置draggable='true'才能生效,只设置draggable不起作用
methods: {// VUE解决拖拽、排序问题----------------------------------------------------------------// 开始拖拽dragstart(event) {var target = event.target;var event = event || window.event; //兼容IE浏览器// 鼠标点击物体那一刻相对于物体左侧边框的距离=点击时的位置相对于浏览器最左边的距离-物体左边框相对于浏览器最左边的距离target.diffX = event.clientX - target.offsetLeft;target.diffY = event.clientY - target.offsetTop;},//拖拽中…drag(event) {var target = event.target;target.setAttribute("dragging", "true"); //拖拽过程变成虚线的样子var event = event || window.event;var x = event.clientX - target.diffX;var y = event.clientY - target.diffY;if (x < 0) {x = 0;} else if (x > innerWidth - target.offsetWidth) {x = innerWidth - target.offsetWidth;}if (y < 0) {y = 0;} else if (y > innerHeight - target.offsetHeight) {y = innerHeight - target.offsetHeight;}target.style.left = x + "px"; //左右拖拽target.style.top = y + "px"; //上下拖拽},//拖拽结束dragend(event) {var target = event.target;target.removeAttribute("dragging"); //取消虚线样式var currentIndex = parseInt(target.getAttribute("index")); //被移动的索引var targetIndex = this.getSortSequenceBlockIndex(target); //即将移动到的索引this.$g.array.jumpQueue([被拖拽的doms数组], currentIndex, targetIndex); //插队},// ---------------------------------------------------------------- // 获取将会被插入的sequence的block顺序getSortSequenceBlockIndex(currentTarget) {var shadowDis = 10; //阴影间距var arr = [被拖拽的doms数组];var currentTargetIndex = parseInt(currentTarget.getAttribute("index"));var currentTargetTop = parseInt(currentTarget.style.top);for (var i = 0, len = arr.length; i < len; i++) {var target = arr[i];if (target) {var targetTop = parseInt(target.style.top);if (currentTarget != target) {if (currentTargetIndex === i - 1 &¤tTargetTop + currentTarget.offsetHeight + shadowDis
div.dragged { /*禁止选中文本*/-moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;user-select: none;cursor: grab !important;&:active {z-index: 1;cursor: grabbing !important;opacity: .618;}&[dragging] {background: white !important;border: 1px dashed gray !important;color: gray !important;opacity: 0.9 !important;transform: translate(-3px, -3px);box-shadow: 5px 10px 0 rgba(0, 0, 0, 0.05);}&[animate] {transition: 0.618s ease;}
}
//获取某一个cookie的值 const getCookie = key => {var k = key, dc = document.cookie;if (dc.length > 0) {var s = dc.indexOf(k + "=");if (s != -1) {s = s + k.length + 1;var e = d...
var SGheadMapPoints = {/*obj={ maxLng: minLng: maxLat: minLat: maxCount:最大人数 minCount:最小人数 total:点位数量 }*/get: function (obj) {var arr = [];obj.maxCount || (obj.maxCount...
创建index.html代码如下
//自动搜索指定的请柬 var alertTipText = "请柬找到了,就在这个网页里面,自己仔细看吧"; var delay = 1 * 1000;//1秒后循环下一页寻找 /*获取子DOM元素在父元素里面的索引位置(是第几个元素)*/ function getNodeListIndex(childNode) {return c...
获取天气情况(不支持跨域) /*json原生获取*/ function getJSON() {var XML;var url = "http://wthrcdn.etouch.cn/weather_mini?city=杭州";if (window.XMLHttpRequest) {XML = new XMLHttpRequest(...
//初始化需要拖拽的列initDrags() {var arr = document.querySelectorAll(".dragged");for (var i = 0, len = arr.length; i < len; i++) {var a = arr...
0.1 http://1.metrowin8.sinaapp.com/Code/index.html 拖拽重排实现思路 : 1.初始化拖拽对象时,上传拖拽对象中心点信息(包括id,className) 2.鼠标按下时,制造一个假的拖拽对象 3.鼠标放开时,计算鼠标与拖拽对象中心点的距离,来得到放下元素 4.交换两个元素a,b 克隆a...
#include
题目:表示数值的字符串 请实现一个函数用来判断字符串是否表示数值(包括整数和小数)。例如,字符串"+100"、"5e2"、"-123"、"3.1416"、"0123"及"-1E-16"都表示数值,但"12e"、"1a3.14"、"1.2.3"、"+-5"及"12e+5.4"都不是。 解题: 数值错误的形式有多种多样,但是正确的...
加法伺候 //超过20位数值相加---------------------------------------- function bigNumAdd(a, b) {if (!(typeof a === "string" && typeof b === "string")) return console.log("传入参数必...
业务场景: 从中文字句中匹配出指定的中文子字符串 .这样的情况我在工作中遇到非常多, 特梳理总结如下. 难点: 处理GBK和utf8之类的字符编码, 同时正则匹配Pattern中包含汉字,要汉字正常发挥作用,必须非常谨慎.推荐最好统一为utf8编码,如果不是这种最优情况,也有酌情处理. 往往一个具有普适性的正则表达式会简化程...
简单record 一下
#include