<style>
#tag{
background: #eee;
cursor: move;
display: flex;overflow: hidden;
}
#tag div{
border: 20px solid #fff;
background: #dddddd;
width: 33.33%;
height: 200px;
flex: none;
}
</style>
<div id="tag"></div>
<script>
var html=""
var tag=document.getElementById('tag');
for(var i=0;i<100;i++){
html+="<div>"+i+"</div>";
}
tag.innerHTML=html;
window.onload = function(){
var timer=null;
var movex=0;
var num=0;
var drag = document.getElementById('tag');
drag.onselectstart= function () {
return false;
}
drag.ondragstart = function () {
return false
}
drag.onmousedown = function(event){
clearInterval(timer)
var event = event || window.event;
var x=event.clientX;
document.onmousemove = function(event){
var event = event || window.event;
movex= event.clientX-x;
console.log(num++,movex);
drag.scrollLeft+=movex
}
document.onmouseup = function(event){
this.onmousemove = null;
this.onmouseup = null;
timer=setInterval(function () {
movex=movex/1.1;
if(Math.abs(movex)<2){
clearInterval(timer)
}
drag.scrollLeft+=movex
},25)
if(typeof drag.releaseCapture!='undefined'){
drag.releaseCapture();
}
}
}
}
</script>