dataarts / dat.gui

Lightweight controller library for JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

name close open [suggest]

jonlepage opened this issue · comments

suppose we have multiple gui, i think it can be a good idea to natively name controler frame with name.

    closed: {
      get: function get$$1() {
        return params.closed;
      },
      set: function set$$1(v) {
        params.closed = v;
        if (params.closed) {
          dom.addClass(_this.__ul, GUI.CLASS_CLOSED);
        } else {
          dom.removeClass(_this.__ul, GUI.CLASS_CLOSED);
        }
        this.onResize();
        if (_this.__closeButton) {
          _this.__closeButton.innerHTML = v ? GUI.TEXT_OPEN +' '+_this.name : GUI.TEXT_CLOSED +' '+_this.name;
        }
      }
    },

image

edit also a disable element will be nice

  Common.extend(controller,                                   {
    disable: function disable(v) {
      this.domElement.style.pointerEvents = v?"none":"auto";
      this.domElement.style.opacity = v?.5:1;
      return controller;
    },

edit and a drag and drop on open close button

    this.__closeButton.innerHTML = GUI.TEXT_CLOSED;
    dom.addClass(this.__closeButton, GUI.CLASS_CLOSE_BUTTON);
    // DRAG DROP
    var parentDiv = document.getElementById(this.name) || this.domElement;
    this.__closeButton.onmousedown = ()=>{ parentDiv._drag = true };
    document.addEventListener('mouseup', (e) => { parentDiv._drag = false; });
    document.addEventListener('mousemove', (e) => {
        if(parentDiv._drag ){
          parentDiv.style.top = `${e.pageY}px`;
          parentDiv.style.left = `${e.pageX-parentDiv.offsetWidth/2}px`;
        }
    });
    if (params.closeOnTop) { ....