()
| 179 | } |
| 180 | |
| 181 | selected_changed() { |
| 182 | //TODO: should the size get overridden if it was set previously and |
| 183 | //then selected was changed from the python side? |
| 184 | if (this.dirty) { |
| 185 | //this change was most probably triggered from the js side and |
| 186 | //should be ignored. |
| 187 | return; |
| 188 | } |
| 189 | //reposition the interval selector and set the selected attribute. |
| 190 | const selected = this.model.get('selected') || []; |
| 191 | if (selected.length === 0) { |
| 192 | this.reset(); |
| 193 | } else if (selected.length != 2) { |
| 194 | // invalid value for selected. Ignoring the value |
| 195 | return; |
| 196 | } else { |
| 197 | let pixels = selected.map(this.scale.scale); |
| 198 | pixels = pixels.sort((a, b) => { |
| 199 | return a - b; |
| 200 | }); |
| 201 | |
| 202 | applyAttrs(this.rect, { |
| 203 | x: pixels[0], |
| 204 | width: pixels[1] - pixels[0], |
| 205 | }).style('display', 'inline'); |
| 206 | this.active = true; |
| 207 | this.update_mark_selected(pixels, undefined); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | adjust_rectangle() { |
| 212 | if (this.model.get('orientation') == 'vertical') { |
no test coverage detected