Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Access component parent node">
  <meta charset="utf-8">
  <script src="https://cdn.rawgit.com/lhorie/mithril.js/next/mithril.js"></script>
</head>
<body>
</body>
</html>
 
div {
  width: 300px;
  height: 300px;
  background-color: #ccc;
}
 
m.mount( document.body, {
  controller(){
    this.position = m.prop( { 
      clientX : 0, 
      clientY : 0 
    } )
  },
  view : ctrl =>
    m( 'div', {
      config : el => {
        el.parentNode.onmousemove = e => {
          ctrl.position( e )
          
          m.redraw()
        }
      }
    }, 
      
      'Mouse is currently at: ',
      
      ctrl.position().clientX,
      
      ' ',
      
      ctrl.position().clientY
    )
} )
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
pelonpelonpro
0viewers