npm install @axetroy/lazy-image
Using with Vue
<template>
<lazy-image style="max-width: 100%;" src="https://example.com/img.png" />
</template>
<script>
import LazyImage from "@axetroy/lazy-image/vue";
export default {
components: {
"lazy-image": LazyImage
}
};
</script>
Prop | Description | Defaults |
---|---|---|
src | Image src url | undefined |
Prop | Description |
---|---|
@enter | trigger when enter into viewport |
@leave | trigger when leave viewport |
Using in React
import React from "react";
import LazyImage from "@axetroy/lazy-image/react";
class App extends React.Component {
render() {
return (
<LazyImage
style={{ maxWidth: "100%" }}
src={"https://example.com/img.png"}
/>
);
}
}
Prop | Description | Defaults |
---|---|---|
src | Image src url | undefined |
onEnter() | trigger when enter into viewport | undefined |
onLeave() | trigger when leave viewport | undefined |
IE / Edge |
Firefox |
Chrome |
Safari |
---|---|---|---|
IE9, IE10, IE11, Edge | last 2 versions | last 2 versions | last 2 versions |
IE11 require polyfill
Object.assign()
IE10 require polyfill
new Set()
andnew Map()
The MIT License