zoukankan      html  css  js  c++  java
  • 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>
    
  • 相关阅读:
    day74test
    day73
    drf节流
    drf面试题及总结
    day72test
    日常积累
    windows 内核下获取进程路径
    转:浅析C++中的this指针
    vc 获取窗口标题GetWindowText
    驱动自定义回调例程
  • 原文地址:https://www.cnblogs.com/zhaowinter/p/15062359.html
Copyright © 2011-2022 走看看