Skip to content

Commit

Permalink
fix initial location bug
Browse files Browse the repository at this point in the history
  • Loading branch information
callmecavs committed Jan 25, 2016
1 parent 288fcc2 commit fefb0bd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dist/layzr.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "layzr.js",
"version": "2.0.1",
"version": "2.0.2",
"description": "A small, fast, and modern library for lazy loading images.",
"homepage": "http://callmecavs.github.io/layzr.js/",
"main": "dist/layzr.min.js",
Expand Down
10 changes: 8 additions & 2 deletions src/layzr.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import knot from 'knot.js'
export default (options = {}) => {
// private

let prevLoc
let prevLoc = getLoc()
let ticking

let nodes
Expand Down Expand Up @@ -38,10 +38,16 @@ export default (options = {}) => {

return instance

// location helper

function getLoc() {
return window.scrollY || window.pageYOffset
}

// debounce helpers

function requestScroll() {
prevLoc = window.scrollY || window.pageYOffset
prevLoc = getLoc()
requestFrame()
}

Expand Down

0 comments on commit fefb0bd

Please sign in to comment.