(rData = this.renderData)
| 46 | } |
| 47 | |
| 48 | protected _render(rData = this.renderData): void { |
| 49 | if (!rData) return; |
| 50 | |
| 51 | const that = this; |
| 52 | const renderList = rData.orig.res.map(d => [d]); |
| 53 | |
| 54 | if (rData.compare) { |
| 55 | rData.compare.res.map((d, i) => renderList[i].push(d)); |
| 56 | } |
| 57 | |
| 58 | let img_pairs = this.div_origs.selectAll('.img_pair').data(renderList); |
| 59 | img_pairs.exit().remove(); |
| 60 | img_pairs = img_pairs.enter().append('div').attr('class', 'img_pair') |
| 61 | .merge(img_pairs); |
| 62 | |
| 63 | let imgs = img_pairs.selectAll('img').data(d => d); |
| 64 | imgs.exit().remove(); |
| 65 | imgs.enter().append('img') |
| 66 | .merge(imgs) |
| 67 | .attr('src', d => d.d) |
| 68 | .attr('width', this._imgWidth > -1 ? this._imgWidth : null); |
| 69 | |
| 70 | |
| 71 | img_pairs.on('click', function (d) { |
| 72 | const eventDetail: ExampleViewMouseEvent = { |
| 73 | caller: d3.select(this), |
| 74 | images: d |
| 75 | }; |
| 76 | |
| 77 | that.eventHandler.trigger( |
| 78 | ExampleView.events.clicked_image_pair, |
| 79 | eventDetail |
| 80 | ) |
| 81 | }) |
| 82 | |
| 83 | img_pairs.on('mouseenter', function (d) { |
| 84 | const eventDetail: ExampleViewMouseEvent = { |
| 85 | caller: d3.select(this), |
| 86 | images: d, |
| 87 | hovered: true |
| 88 | }; |
| 89 | |
| 90 | that.eventHandler.trigger( |
| 91 | ExampleView.events.hovered_image_pair, |
| 92 | eventDetail |
| 93 | ) |
| 94 | }) |
| 95 | img_pairs.on('mouseleave', function (d) { |
| 96 | const eventDetail: ExampleViewMouseEvent = { |
| 97 | caller: d3.select(this), |
| 98 | images: d, |
| 99 | hovered: false |
| 100 | }; |
| 101 | |
| 102 | that.eventHandler.trigger( |
| 103 | ExampleView.events.hovered_image_pair, |
| 104 | eventDetail |
| 105 | ) |
no test coverage detected