一 拖拽事件
- draggable=“true”:对象可以被拖拽;
- 拖拽事件:drop drap;
- 开始拖动:ondragstart;
- 结束拖动:ondragend //ondragover;
- 开始拖动鼠标进入的时候: ondragenter;
- 拖动结束鼠标离开的时候:ondragleave;
- 前进:history.go(1);
倒退:history.go(-1);
前进:history.forward();
倒退:history.back();
bom 浏览器对象模型
- 滚轮事件:onmousewheel;
- 离开页面时:onbeforeunload;
- 手机触屏:touchstart touchmove touchend;
区分四个方向:
var clientx = endx - startx;
var clienty = endy - starty;
if (Math.abs(clientx) > Math.abs(clienty) && clientx > 0) {
console.log("right");
}
else if (Math.abs(clientx) > Math.abs(clienty) && clientx < 0) {
console.log("left");
}
else if (Math.abs(clientx) < Math.abs(clienty) && clienty > 0) {
console.log("down");
}
else if (Math.abs(clientx) < Math.abs(clienty) && clienty < 0) {
console.log("up");
}
})