Skip to content

Commit e34aacf

Browse files
authored
Tweak wording of .passive modifier explanation
1 parent f6e4596 commit e34aacf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/v2/guide/events.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,18 @@ Unlike the other modifiers, which are exclusive to native DOM events, the `.once
207207

208208
> New in 2.3.0+
209209
210+
Vue also offers the `.passive` modifier, corresponding to [`addEventListener`'s `passive` option](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Parameters).
211+
210212
``` html
211-
<!-- the scroll event will not cancel the default scroll behavior -->
213+
<!-- the scroll event's default behavior (scrolling) will happen -->
214+
<!-- immediately, instead of waiting for `onScroll` to complete -->
215+
<!-- in case it contains `event.preventDefault()` -->
212216
<div v-on:scroll.passive="onScroll">...</div>
213217
```
214218

215-
In addition to these modifiers, Vue provides `.passive` modifier to improve the performance on mobile especially. For example, when performing a scroll, the browser will scroll after the process has completed because the browser doesn’t know if the event is going to call `event.preventDefault()` within its handler. `.passive` modifier can be used to tell the browser that this event will not cancel the default event behavior in advance.
219+
The `.passive` modifier is especially useful for improving performance on mobile devices.
216220

217-
<p class="tip">Don't use `.passive` and `.prevent` together. Passive handler can't prevent default event.</p>
221+
<p class="tip">Don't use `.passive` and `.prevent` together, because `.prevent` will be ignored and your browser will probably show you a warning. Remember, `.passive` communicates to the browser that you _don't_ want to prevent the event's default behavior.</p>
218222

219223
## Key Modifiers
220224

0 commit comments

Comments
 (0)