Skip to content
Snippets Groups Projects
Select Git revision
  • 2b5f62c42265e82e49372920a55bd7007943b803
  • master default protected
  • leo
  • dex
  • pendulum
  • apfelstruder
  • littlerascal
7 results

three.module.js

Blame
  • button.js 1.19 KiB
    /*
    
    contact
    
    */
    
    import { Hunkify, Input, Output, State } from '../hunks.js'
    
    function Button() {
        Hunkify(this, 'Button')
    
        let onclk = new Output('boolean', 'onclick', this)
        this.outputs.push(onclk)
        /* aspirationally
        this.outputs.mousedown
        this.outputs.mouseup
        */
        /*
        let strang = new State('string', 'strng', 'start value')
        let numbr = new State('number', 'nmbr', 101)
        let blen = new State('boolean', 'bln', false)
        this.states.push(strang, numbr, blen)
        */
    
        this.dom = {}
    
        this.init = () => {
            // manager calls this once
            this.log('HELLO BUTTON')
            this.dom = $('<div>').get(0)
        }
    
        this.onload = (dom) => {
          // function equivalent, our .dom element is loaded into ~ the d o m ~
          let contact = $('<div>').addClass('btn').append('! contact !').get(0)
          $(this.dom).append(contact)
          contact.addEventListener('click', (evt) => {
              //console.log('button hunk down')
              if(onclk.io()){
                console.warn("button attempts to push to occupied output")
              } else {
                onclk.put(true)
              }
          })
        }
    
        this.loop = () => {
            // ... 
        }
    }
    
    export default Button