原生js实现拖动排序动画效果代码

代码语言:html

所属分类:拖放

代码描述:原生js实现拖动排序动画效果代码,拖动的同时还可以计数。

代码标签: 拖动排序

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">



    <style>
        .column {
        	background-color: #ccc;
        	border-radius: 10px;
        	border: 2px solid #666666;
        	box-shadow: inset 0 0 3px #000;
        	cursor: move;
        	float: left;
        	height: 150px;
        	margin-bottom: 30px;
        	margin-right: 5px;
        	text-align: center;
        	width: 150px;
        }
        
        .column header {
        	background: linear-gradient(to right, rgb(0,0,0), rgb(79,79,79), rgb(21,21,21));
        	border-bottom: 1px solid #ddd;
        	border-top-left-radius: 10px;
        	border-top-right-radius: 10px;
        	box-shadow: 5px;
        	color: #fff;
        	padding: 5px;
        	text-shadow: #000 0 1px;
        }
        
        .column {
        	transition: transform 0.2s ease-out;
        }
        
        .column.over {
        	border: 2px dashed #000;
        }
        
        .column.moving {
        	opacity: 0.25;
        	transform: scale(0.8);
        }
        
        .column .count {
        	font-weight: bold;
        	padding-top: 15px;
        	text-shadow: #fff 0 1px;
        }
    </style>



</head>

<body>
    <div class="container" >
        <h1 class="page-header">Native HTML5 Drag and Drop <small>Full Demo</small></h1>
        <div id="columns-full" class="columns clearfix">
            <div class="column" draggable="true">
                <header>A</header>
                <div class="count" data-col-moves="0"></div>
            </div>
            <div class="column" draggable="true">
                <header>B</header>
                <div class="count" data-col-moves="0"></div>
            </div>
            <div class="column" draggable="true">
                <header>C</header>
                <div class="count" data-col-moves="0"></div>
            </div>
            <div class="column" draggable="true">
                <header>D</header>
                <div class="count" data-col-moves="0"></div>
            </div>
        </div>

    </div>

    <script>
        // Full example
        (function () {
          var id_ = 'columns-full';
          var cols_ = document.querySelectorAll('#' + id_ + ' .column');
          var dragSrcEl_ = null;
        
          this.handleDragStart = function (e) {
       .........完整代码请登录后点击上方下载按钮下载查看

网友评论0