* Renders view. * @protected * @return {HTMLElement}
()
| 47 | * @return {HTMLElement} |
| 48 | */ |
| 49 | render () { |
| 50 | this._$content = View.createElement('div', { |
| 51 | className: 'pipe__content' |
| 52 | }) |
| 53 | |
| 54 | this._$scrollHandleLeft = View.createElement('div', { |
| 55 | className: |
| 56 | 'pipe__scroll-handle pipe__scroll-handle--left ' + |
| 57 | 'pipe__scroll-handle--disabled', |
| 58 | onMouseEnter: this.scrollHandleDidStart.bind(this, 0), |
| 59 | onDragEnter: this.scrollHandleDidStart.bind(this, 0), |
| 60 | onMouseLeave: this.scrollHandleDidStop.bind(this), |
| 61 | onDragLeave: this.scrollHandleDidStop.bind(this) |
| 62 | }) |
| 63 | |
| 64 | this._$scrollHandleRight = View.createElement('div', { |
| 65 | className: 'pipe__scroll-handle pipe__scroll-handle--right', |
| 66 | onMouseEnter: this.scrollHandleDidStart.bind(this, 1), |
| 67 | onDragEnter: this.scrollHandleDidStart.bind(this, 1), |
| 68 | onMouseLeave: this.scrollHandleDidStop.bind(this), |
| 69 | onDragLeave: this.scrollHandleDidStop.bind(this) |
| 70 | }) |
| 71 | |
| 72 | // Bind to existing pipe element if any |
| 73 | let $root = document.querySelector('.pipe') |
| 74 | if ($root === null) { |
| 75 | $root = View.createElement('div') |
| 76 | $root.classList.add('pipe') |
| 77 | } |
| 78 | |
| 79 | // Bind drag events |
| 80 | $root.ondrop = this.dragDidDrop.bind(this) |
| 81 | $root.ondragenter = this.dragDidEnterPipe.bind(this) |
| 82 | $root.ondragover = this.dragDidOverPipe.bind(this) |
| 83 | |
| 84 | // Bind to existing scrollable if any |
| 85 | this._$scrollable = $root.querySelector('.pipe__scrollable') |
| 86 | if (this._$scrollable === null) { |
| 87 | this._$scrollable = View.createElement('div', { |
| 88 | className: 'pipe__scrollable' |
| 89 | }) |
| 90 | } |
| 91 | |
| 92 | this._$scrollable.appendChild(this._$content) |
| 93 | this._$scrollable.appendChild(this._$scrollHandleLeft) |
| 94 | this._$scrollable.appendChild(this._$scrollHandleRight) |
| 95 | |
| 96 | $root.appendChild(this._$scrollable) |
| 97 | $root.addEventListener('wheel', this.mouseDidWheel.bind(this)) |
| 98 | return $root |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Injects subview's root element into own DOM structure. |
nothing calls this directly
no test coverage detected