Advertisement
dhshin

event-fin

Mar 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.00 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <meta charset = "utf-8">
  3. <body>
  4.     <svg height="500">
  5.         <rect transform="translate(100, 100)" width="50" height="50"></rect>
  6.     </svg>
  7.     <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.3/d3.min.js"></script>
  8.     <script>
  9.  
  10.       d3.selectAll('rect')
  11.         .on('mouseenter.e1', function() {
  12.           d3.select(this)
  13.             .style('fill', 'red');
  14.           console.log('mouseenter.e1');
  15.         })
  16.         .on('mouseenter.e2', function() {
  17.           d3.select(this)
  18.             .attr('width', 100)
  19.             .attr('height', 100);
  20.           console.log('mouseenter.e2');
  21.         })
  22.         .on('mouseleave.e1', function() {
  23.           d3.select(this)
  24.             .style('fill', 'black');
  25.           console.log('mouseleave.e1');
  26.         })
  27.         .on('mouseleave.e2', function() {
  28.           d3.select(this)
  29.             .attr('width', 50)
  30.             .attr('height', 50);
  31.           console.log('mouseleave.e2');
  32.         })
  33.      
  34.     </script>
  35. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement