| 4098 | } |
| 4099 | |
| 4100 | class HighlightComponent { |
| 4101 | constructor (props) { |
| 4102 | this.props = props |
| 4103 | etch.initialize(this) |
| 4104 | if (this.props.flashRequested) this.performFlash() |
| 4105 | } |
| 4106 | |
| 4107 | destroy () { |
| 4108 | if (this.timeoutsByClassName) { |
| 4109 | this.timeoutsByClassName.forEach((timeout) => { |
| 4110 | window.clearTimeout(timeout) |
| 4111 | }) |
| 4112 | this.timeoutsByClassName.clear() |
| 4113 | } |
| 4114 | |
| 4115 | return etch.destroy(this) |
| 4116 | } |
| 4117 | |
| 4118 | update (newProps) { |
| 4119 | this.props = newProps |
| 4120 | etch.updateSync(this) |
| 4121 | if (newProps.flashRequested) this.performFlash() |
| 4122 | } |
| 4123 | |
| 4124 | performFlash () { |
| 4125 | const {flashClass, flashDuration} = this.props |
| 4126 | if (!this.timeoutsByClassName) this.timeoutsByClassName = new Map() |
| 4127 | |
| 4128 | // If a flash of this class is already in progress, clear it early and |
| 4129 | // flash again on the next frame to ensure CSS transitions apply to the |
| 4130 | // second flash. |
| 4131 | if (this.timeoutsByClassName.has(flashClass)) { |
| 4132 | window.clearTimeout(this.timeoutsByClassName.get(flashClass)) |
| 4133 | this.timeoutsByClassName.delete(flashClass) |
| 4134 | this.element.classList.remove(flashClass) |
| 4135 | requestAnimationFrame(() => this.performFlash()) |
| 4136 | } else { |
| 4137 | this.element.classList.add(flashClass) |
| 4138 | this.timeoutsByClassName.set(flashClass, window.setTimeout(() => { |
| 4139 | this.element.classList.remove(flashClass) |
| 4140 | }, flashDuration)) |
| 4141 | } |
| 4142 | } |
| 4143 | |
| 4144 | render () { |
| 4145 | const { |
| 4146 | className, screenRange, lineHeight, |
| 4147 | startPixelTop, startPixelLeft, endPixelTop, endPixelLeft |
| 4148 | } = this.props |
| 4149 | const regionClassName = 'region ' + className |
| 4150 | |
| 4151 | let children |
| 4152 | if (screenRange.start.row === screenRange.end.row) { |
| 4153 | children = $.div({ |
| 4154 | className: regionClassName, |
| 4155 | style: { |
| 4156 | position: 'absolute', |
| 4157 | boxSizing: 'border-box', |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…