Skip to content

Commit

Permalink
add: config method
Browse files Browse the repository at this point in the history
  • Loading branch information
hilongjw committed Feb 8, 2017
1 parent a271e63 commit f460407
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,20 @@ vm.$Lazyload.$off('loaded', handler)
vm.$Lazyload.$off('loaded')
```

### LazyLoadHandler

`vm.$Lazyload.lazyLoadHandler`

Manually trigger lazy loading position calculation

#### Example

```javascript

this.$Lazyload.lazyLoadHandler()

```

### Performance

```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-lazyload",
"version": "1.0.0-rc10",
"version": "1.0.0-rc11",
"description": "Vue module for lazy-loading images in your vue.js applications.",
"main": "vue-lazyload.js",
"scripts": {
Expand Down
4 changes: 0 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ export default {
const lazy = new LazyClass(options)
const isVueNext = Vue.version.split('.')[0] === '2'

lazy.config = (options = {}) => {
lazy && Object.assign(lazy.options, options)
}

Vue.prototype.$Lazyload = lazy
Vue.component('lazy-component', LazyComponent(lazy))

Expand Down
17 changes: 16 additions & 1 deletion src/lazy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import { remove, some, find, _, throttle, supportWebp, getDPR, getBestSelectionFromSrcset } from './util'
import {
remove,
some,
find,
_,
throttle,
supportWebp,
getDPR,
getBestSelectionFromSrcset,
assign
} from './util'

import ReactiveListener from './listener'

const DEFAULT_URL = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
Expand Down Expand Up @@ -33,6 +44,10 @@ export default function (Vue) {
}, 200)
}

config (options = {}) {
assign(this.options, options)
}

addLazyBox (vm) {
this.ListenerQueue.push(vm)
this.options.hasbind = true
Expand Down
Loading

0 comments on commit f460407

Please sign in to comment.