Fix mw.viewport.isElementInViewport with scrolled page
authorjoakin <joaquin@chimeces.com>
Thu, 10 Mar 2016 13:10:30 +0000 (13:10 +0000)
committerjoakin <joaquin@chimeces.com>
Thu, 10 Mar 2016 13:19:50 +0000 (13:19 +0000)
commitb65cd87d7b5bd50063951d5107a1c28e77175194
tree2fcdcffcbb68b62c3c58d5633f7be075120dc1a1
parenta92a23e8a24456c56957144808eb8d62a07a227c
Fix mw.viewport.isElementInViewport with scrolled page

With a scrolled page the function would return false since it assumed that
getBoundingClientRect returns the offset when in reality it returns the offset
relative to the window viewport.

This implementation keeps the ability to specify custom viewport rects. If we
wanted to just rely on the window viewport the implementation could be changed
with getBoundingClientRect to be much simpler.

Bug: T129466
Change-Id: I56142fbd1177fe47171a1874f73b7a8359c282ee
resources/src/mediawiki/mediawiki.viewport.js
tests/qunit/suites/resources/mediawiki/mediawiki.viewport.test.js