Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,24 @@ Default: `true`

Add an addtional condition to check if it should invoke the handler function, for example you don't want it to be invoked again as it's loading.

#### offset

Type: `Number` `object`<br>
Default: `0`

By default, the `<mugen-scroll>`' is considered in viewport if it breaks any edge of the viewport. This can be used to set an offset from that edge. For example, an offset of `100` will consider the element in viewport if it breaks any edge of the viewport by at least `100` pixels. offset can be a positive or negative integer.

Offset can also be set per-direction by passing an object.

```js
{
top: 100,
right: 75,
bottom: 50,
left: 25
}
```

#### threshold

Type: `number`<br>
Expand Down
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const MugenScroll = {
type: Boolean,
default: true
},
offset: {
type: [Number, Object],
default: 0
},
threshold: {
type: Number,
default: 0
Expand All @@ -33,6 +37,7 @@ const MugenScroll = {
checkInView() {
const execute = () => {
const inView = inViewport(this.$refs.scroll, {
offset: this.offset,
threshold: this.threshold
})
if (this.shouldHandle && inView) {
Expand Down