Skip to content

Instantly share code, notes, and snippets.

@akopcz2
Created December 5, 2018 22:53
Show Gist options
  • Select an option

  • Save akopcz2/3b36417dd80421bce3a3040c36be620a to your computer and use it in GitHub Desktop.

Select an option

Save akopcz2/3b36417dd80421bce3a3040c36be620a to your computer and use it in GitHub Desktop.
button resizer
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