Skip to content

Commit

Permalink
add $.fn.scrollTop()
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Oct 3, 2012
1 parent e92afc9 commit e8399bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/zepto.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ var Zepto = (function() {
;(when === undefined ? !$(this).hasClass(newName) : when) ?
$(this).addClass(newName) : $(this).removeClass(newName)
})
},
scrollTop: function(){
if (!this.length) return
return ('scrollTop' in this[0]) ? this[0].scrollTop : this[0].scrollY
}
}

Expand Down
5 changes: 5 additions & 0 deletions test/zepto.html
Original file line number Diff line number Diff line change
Expand Up @@ -2063,6 +2063,11 @@ <h1>Zepto DOM unit tests</h1>
t.assertEqual($els.slice().length, 3)
t.assertEqual(typeof $els.slice().ready, 'function')
t.assertEqual($els.slice(-1)[0].className, 'slice3')
},

testScrollTop: function(t) {
t.assert($(window).scrollTop() >= 0)
t.assert($(document.body).scrollTop() >= 0)
}
})

Expand Down

0 comments on commit e8399bb

Please sign in to comment.