Created
December 5, 2018 22:53
-
-
Save akopcz2/3b36417dd80421bce3a3040c36be620a to your computer and use it in GitHub Desktop.
button resizer
This file contains hidden or 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
| resizeBtns() { | |
| const bodyWidth = document.body.clientWidth; | |
| const img = this.element.querySelector(`.${this.settings.imgClassname}`); | |
| const imgCR = img.getBoundingClientRect(); | |
| const imgRatio = imgCR.height / imgCR.width; | |
| var sheet = document.createElement('style') | |
| sheet.innerHTML = `${this.settings.prevButtonSelector}, ${this.settings.nextButtonSelector} { | |
| height: calc(${100 * imgRatio}vw - ${(bodyWidth - imgCR.width + this.getScrollbarWidth()) * imgRatio}px); | |
| } | |
| .tns-nav { | |
| top: calc(${100 * imgRatio}vw - ${(bodyWidth - imgCR.width + this.getScrollbarWidth()) * imgRatio + 25}px); | |
| }`; | |
| document.body.appendChild(sheet); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment