|
125 | 125 | if (style.height) {
|
126 | 126 | style.removeProperty('height');
|
127 | 127 | }
|
| 128 | + }, |
| 129 | + getScrollParent: function(el) { |
| 130 | + var returnEl; |
| 131 | + if (el == null) { |
| 132 | + returnEl = null; |
| 133 | + } else if (el.scrollHeight > el.clientHeight) { |
| 134 | + returnEl = el; |
| 135 | + } else { |
| 136 | + returnEl = Utils.getScrollParent(el.parentNode); |
| 137 | + } |
| 138 | + return returnEl; |
| 139 | + }, |
| 140 | + updateScrollPosition: function(el, ui, distance) { |
| 141 | + // is widget in view? |
| 142 | + var rect = el.getBoundingClientRect(); |
| 143 | + var innerHeightOrClientHeight = (window.innerHeight || document.documentElement.clientHeight); |
| 144 | + if (rect.top < 0 || |
| 145 | + rect.bottom > innerHeightOrClientHeight |
| 146 | + ) { |
| 147 | + // set scrollTop of first parent that scrolls |
| 148 | + // if parent is larger than el, set as low as possible |
| 149 | + // to get entire widget on screen |
| 150 | + var offsetDiffDown = rect.bottom - innerHeightOrClientHeight; |
| 151 | + var offsetDiffUp = rect.top; |
| 152 | + var scrollEl = Utils.getScrollParent(el); |
| 153 | + var prevScroll = scrollEl.scrollTop; |
| 154 | + if (scrollEl != null) { |
| 155 | + if (rect.top < 0 && distance < 0) { |
| 156 | + // moving up |
| 157 | + if (el.offsetHeight > innerHeightOrClientHeight) { |
| 158 | + scrollEl.scrollTop += distance; |
| 159 | + } else { |
| 160 | + scrollEl.scrollTop += Math.abs(offsetDiffUp) > Math.abs(distance) ? distance : offsetDiffUp; |
| 161 | + } |
| 162 | + } else if (distance > 0) { |
| 163 | + // moving down |
| 164 | + if (el.offsetHeight > innerHeightOrClientHeight) { |
| 165 | + scrollEl.scrollTop += distance; |
| 166 | + } else { |
| 167 | + scrollEl.scrollTop += offsetDiffDown > distance ? distance : offsetDiffDown; |
| 168 | + } |
| 169 | + } |
| 170 | + // move widget y by amount scrolled |
| 171 | + ui.position.top += scrollEl.scrollTop - prevScroll; |
| 172 | + } |
| 173 | + } |
128 | 174 | }
|
129 | 175 | };
|
130 | 176 |
|
|
1106 | 1152 | }
|
1107 | 1153 |
|
1108 | 1154 | if (event.type == 'drag') {
|
| 1155 | + var distance = ui.position.top - node._prevYPix; |
| 1156 | + node._prevYPix = ui.position.top; |
| 1157 | + Utils.updateScrollPosition(el[0], ui, distance); |
1109 | 1158 | if (el.data('inTrashZone') || x < 0 || x >= self.grid.width || y < 0 ||
|
1110 | 1159 | (!self.grid.float && y > self.grid.getGridHeight())) {
|
1111 | 1160 | if (!node._temporaryRemoved) {
|
|
1177 | 1226 | node.el = self.placeholder;
|
1178 | 1227 | node._beforeDragX = node.x;
|
1179 | 1228 | node._beforeDragY = node.y;
|
| 1229 | + node._prevYPix = ui.position.top; |
1180 | 1230 |
|
1181 | 1231 | self.dd.resizable(el, 'option', 'minWidth', cellWidth * (node.minWidth || 1));
|
1182 | 1232 | self.dd.resizable(el, 'option', 'minHeight', strictCellHeight * (node.minHeight || 1));
|
|
0 commit comments