Created
February 13, 2019 08:24
-
-
Save dongsik-yoo/59bce7b43bb0fff9e5f4d9908c6fc553 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get all exceed paragraphs | |
* @param {HTMLElement} pageBodyElement - page body element | |
* @param {number} pageBodyBottom - page bottom | |
* @returns {Array.<HTMLElement>} all exceed paragraph array | |
*/ | |
_getExceedAllParagraphs(pageBodyElement, pageBodyBottom) { | |
const paragraphs = pageBodyElement.querySelectorAll('p'); | |
const {length} = paragraphs; | |
const exceedParagraphs = []; | |
for (let i = 0; i < length; i += 1) { | |
const paragraph = paragraphs[i]; | |
const paragraphBottom = this._getBottom(paragraph); | |
if (pageBodyBottom < paragraphBottom) { | |
exceedParagraphs.push(paragraph); | |
} | |
} | |
// Remain a bigger paragraph than page height. | |
if (paragraphs.length === exceedParagraphs.length) { | |
exceedParagraphs.shift(); | |
} | |
return exceedParagraphs; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment