Fixing viewport shuffling due to image load

Introduced new method ".loadImages()" in posts client side lib
to handle viewport height changes when loading images. Requires
nodebb-plugin-markdown@5.0.0

@BenLubar @boomzillawtf
This commit is contained in:
Julian Lam
2016-03-27 15:52:26 -04:00
parent 5d4f61ec96
commit 3e2231d2cb
7 changed files with 126 additions and 13 deletions

View File

@@ -309,6 +309,23 @@
return labels;
},
/* Retrieved from http://stackoverflow.com/a/7557433 @ 27 Mar 2016 */
isElementInViewport: function(el) {
//special bonus for those using jQuery
if (typeof jQuery === "function" && el instanceof jQuery) {
el = el[0];
}
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */
);
},
// get all the url params in a single key/value hash
params: function(options) {
var a, hash = {}, params;