MCPcopy Create free account
hub / github.com/rough-stuff/wired-elements / _didRender

Method _didRender

packages/wired-toggle/wired-toggle.js:102–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

100 }
101
102 _didRender() {
103 const svg = this.shadowRoot.getElementById('svg');
104 this._clearNode(svg);
105 const s = { width: (this.height || 32) * 2.5, height: this.height || 32 };
106 svg.setAttribute("width", s.width);
107 svg.setAttribute("height", s.height);
108 wired.rectangle(svg, 0, 0, s.width, s.height);
109 this.knob = wired.ellipse(svg, s.height / 2, s.height / 2, s.height, s.height);
110 this.knobOffset = s.width - s.height;
111 this.knob.style.transition = "all 0.3s ease";
112 this.knob.style.transform = this.checked ? ("translateX(" + this.knobOffset + "px)") : "";
113 const cl = this.knob.classList;
114 if (this.checked) {
115 cl.remove("unchecked");
116 cl.add("checked");
117 } else {
118 cl.remove("checked");
119 cl.add("unchecked");
120 }
121 this.classList.remove('pending');
122 this._setAria();
123 this._attachEvents();
124 }
125
126 _attachEvents() {
127 if (!this._keyboardAttached) {

Callers

nothing calls this directly

Calls 5

_clearNodeMethod · 0.95
_setAriaMethod · 0.95
_attachEventsMethod · 0.95
rectangleMethod · 0.80
ellipseMethod · 0.80

Tested by

no test coverage detected