Commit 4abcf67
committed
Emit @layout-ready at a later, correct time
As it was, if one was to investigate the size of GridItems in an
@layout-ready event handler, the size was not yet correct.
The problem was that layout-ready was emitted in mounted() after a
call to onWindowResize(). onWindowResize() set the width with
this.width = this.$refs.item.offsetWidth
but the width (and hence size generally) change only actually took
effect in the watcher for 'width' with:
this.eventBus.$emit("updateWidth", this.width);
and in addition, that was done inside a this.$nextTick() for some
undocumented reason.
Now, the layout-ready event is emitted after "updateWidth" has been
emitted, so callers can investigate GridItem sizes safely.
Care is taken in the width watcher to only emit layout-ready the first
time width is set, and layout-ready is emitted in a this.$nextTick()
so that the 'updateWidth' has a chance to take effect in the child
GridItems before layout-ready is emitted. See comment in
GridLayout.vue for more details.1 parent 0f5d445 commit 4abcf67
1 file changed
+26
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | | - | |
178 | 176 | | |
179 | 177 | | |
180 | 178 | | |
181 | 179 | | |
182 | | - | |
| 180 | + | |
183 | 181 | | |
184 | 182 | | |
185 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
186 | 209 | | |
187 | 210 | | |
188 | 211 | | |
| |||
0 commit comments