Skip to content

Commit 1c7cdaf

Browse files
committed
Code cleanup
1 parent 670748f commit 1c7cdaf

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

intro.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -311,27 +311,34 @@
311311
//change to new intro item
312312
targetElement.className += " introjs-relativePosition";
313313
}
314-
315-
if (!elementInViewport(targetElement)) {
314+
315+
if (!_elementInViewport(targetElement)) {
316316
var rect = targetElement.getBoundingClientRect()
317-
top = rect.bottom-rect.height,
318-
bottom = rect.bottom-window.innerHeight;
319-
317+
top = rect.bottom - rect.height,
318+
bottom = rect.bottom - window.innerHeight;
319+
320320
// Scroll up
321321
if (top < 0) {
322-
window.scrollBy(0, top-30); // 30px padding from edge to look nice
323-
322+
window.scrollBy(0, top - 30); // 30px padding from edge to look nice
323+
324324
// Scroll down
325325
} else {
326-
window.scrollBy(0, bottom+100); // 70px + 30px padding from edge to look nice
326+
window.scrollBy(0, bottom + 100); // 70px + 30px padding from edge to look nice
327327
}
328-
}
328+
}
329329
}
330-
331-
// http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
332-
function elementInViewport(el) {
330+
331+
/**
332+
* Add overlay layer to the page
333+
* http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
334+
*
335+
* @api private
336+
* @method _elementInViewport
337+
* @param {Object} el
338+
*/
339+
function _elementInViewport(el) {
333340
var rect = el.getBoundingClientRect();
334-
341+
335342
return (
336343
rect.top >= 0 &&
337344
rect.left >= 0 &&

0 commit comments

Comments
 (0)