File tree Expand file tree Collapse file tree 1 file changed +20
-13
lines changed Expand file tree Collapse file tree 1 file changed +20
-13
lines changed Original file line number Diff line number Diff line change 311
311
//change to new intro item
312
312
targetElement . className += " introjs-relativePosition" ;
313
313
}
314
-
315
- if ( ! elementInViewport ( targetElement ) ) {
314
+
315
+ if ( ! _elementInViewport ( targetElement ) ) {
316
316
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
+
320
320
// Scroll up
321
321
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
+
324
324
// Scroll down
325
325
} 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
327
327
}
328
- }
328
+ }
329
329
}
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 ) {
333
340
var rect = el . getBoundingClientRect ( ) ;
334
-
341
+
335
342
return (
336
343
rect . top >= 0 &&
337
344
rect . left >= 0 &&
You can’t perform that action at this time.
0 commit comments