sortable.js animation 动画

sortable.js animation 动画,如果不设置animation属性拖拽时的过渡效果会非常生硬。

animations属性

属性名称
类型说明
animation整型0表示没有过渡效果

代码例子

例子

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>sortable.js animation属性例子</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui">
    <script src="http://www.itxst.com/package/sortable/sortable.min.js"></script>
    <style> 
        .itxst {
            margin: 10px auto;
            width: 40%;
            float: left;
            margin-right: 10px;
        }
        .itxst div {
                padding:6px;
                background-color: #fdfdfd;
                border: solid 1px #eee;
                margin-bottom: 10px;
                cursor: move;
            }
        #msg {
        clear:both;
        width:100%;
        }
    </style>
</head>
<body> 
<div class="box">
    <div id="g1" class="itxst">
        <div>animation过渡动画</div>
        <div class="item" data-id="1" >item 1</div>
        <div class="item" data-id="2" >item 2</div>
        <div class="item" data-id="3" >item 3</div>
    </div> 
</div>
<div id="msg"></div>
<script>
    //第一组 
    var g1 = document.getElementById('g1');
    var ops1 = {
        animation: 1000,
        draggable: ".item", 
        //拖动结束
        onEnd: function (evt) {
            console.log(evt);
            //获取拖动后的排序
            var arr = sortable1.toArray();
            document.getElementById("msg").innerHTML = "A组排序结果:" + JSON.stringify(arr);
        },
    }; 
    var sortable1 = Sortable.create(g1, ops1);
</script>
</body>
</html>