• d3拖拽


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            .container {
                 600px;
                height: 600px;
                background-color: aquamarine;
                position: relative;
            }
            .a {
                 100px;
                height: 100px;
                background-color: yellowgreen;
                position: absolute;
            }
            .dragging {
                background-color: red;
            }
        </style>
    </head>
    <body>
        <div class='container' id='container'>
            <div class="a"></div>
        </div>
        <script src="https://d3js.org/d3.v7.min.js"></script>
        <script>
            d3.selectAll(".a").call(
                d3.drag()
                    .on('start', function(d) {
                        d3.select(this).classed("dragging", true)
                        console.log('start')
                    })
                    .on("end", function (d) {
                        d3.select(this).classed("dragging", false)
                        console.log("end");
                    })
                    .on('drag', function(d) {
                        console.log(d3.select(this))
                        d3.select(this)
                            .style("left", function() {
                                return  d.x + 'px'
                            })
                            .style("top", function() {
                                return d.y + 'px'
                            });
                    })
            )
        </script>
    </body>
    </html>
    
  • 相关阅读:
    源代码的下载和编译
    搭建Android开发环境
    Git使用入门
    Android系统构架
    Android深度探索心得<9>
    Android深度探索心得<10>
    Android深度探索心得<8>
    android深度探索xinde < 7>
    android深度探索xinde < 5>
    android深度探索xinde < 6>
  • 原文地址:https://www.cnblogs.com/zhaowinter/p/15062359.html
Copyright © 2020-2023  润新知