forked from nuxt/image
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: emit native
<img>
events (nuxt#416)
- Loading branch information
Showing
7 changed files
with
60 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
title: Events | ||
category: API | ||
description: 'Listening to native events emitted by the contained img tag' | ||
--- | ||
|
||
Native events emitted by the `<img>` element contained by `<nuxt-img>` and `<nuxt-picture>` components are re-emitted and can be listened to. | ||
|
||
**Example:** Listen to the native `onLoad` event from `<nuxt-img>` | ||
|
||
```html | ||
<nuxt-img | ||
src="/images/colors.jpg" | ||
width="500" | ||
height="500" | ||
@load="doSomethingOnLoad" | ||
/> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
<template> | ||
<div> | ||
<nuxt-img src="/images/colors.jpg" width="500" height="500" /> | ||
<nuxt-img src="/images/colors.jpg" width="500" height="500" @load="isLoaded = true" /> | ||
<p>Received onLoad event: {{ isLoaded }}</p> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
export default Vue.extend({ | ||
data () { | ||
return { | ||
isLoaded: false | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
<template> | ||
<div> | ||
<nuxt-picture src="/images/colors.jpg" width="500" height="500" /> | ||
<nuxt-picture src="/images/colors.jpg" width="500" height="500" @load="isLoaded = true" /> | ||
<p>Received onLoad event: {{ isLoaded }}</p> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
export default Vue.extend({ | ||
data () { | ||
return { | ||
isLoaded: false | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters