Comparing version 1.1.0 to 1.1.1
@@ -1,1 +0,1 @@ | ||
"use strict";exports.__esModule=!0,exports.default=_default;var carouselElements,carouselContainer,arrowLeftElement,arrowRightElement,currentElement;function _default(a){var b=a.container,c=a.elements,d=a.arrowLeft,e=a.arrowRight;carouselContainer=b,carouselElements=Array.from(c),arrowLeftElement=d,arrowRightElement=e,currentElement=carouselElements[0];carouselContainer.clientWidth>getTotalWidthOfItems()||(carouselContainer.style="\n display:flex;\n justify-content: flex-start;\n flex-wrap:nowrap;\n overflow:hidden;",arrowLeftElement.addEventListener("click",scrollToLeft),arrowRightElement.addEventListener("click",scrollToRight))}function scrollToLeft(){carouselContainer.scroll({left:carouselContainer.scrollLeft-getWidthPlusPaddingAndMargin(currentElement),behavior:"smooth"}),backPointer()}function scrollToRight(){carouselContainer.scroll({left:carouselContainer.scrollLeft+getWidthPlusPaddingAndMargin(currentElement),behavior:"smooth"}),advancePointer()}function advancePointer(){var a=carouselElements.indexOf(currentElement);a<carouselElements.length-1&&(currentElement=carouselElements[++a])}function backPointer(){var a=carouselElements.indexOf(currentElement);0<a&&(currentElement=carouselElements[--a])}function getTotalWidthOfItems(){return carouselElements.map(function(a){return a.clientWidth}).reduce(function(a,b){return a+b})}function getWidthPlusPaddingAndMargin(a){return parseInt(window.getComputedStyle(a).width)+parseInt(window.getComputedStyle(a).paddingLeft)+parseInt(window.getComputedStyle(a).paddingRight)+parseInt(window.getComputedStyle(a).marginLeft)+parseInt(window.getComputedStyle(a).marginRight)} | ||
"use strict";exports.__esModule=!0,exports.default=_default;var carouselElements,carouselContainer,arrowLeftElement,arrowRightElement,currentElement;function _default(a){var b=a.container,c=a.elements,d=a.arrowLeft,e=a.arrowRight;carouselContainer=b,carouselElements=Array.from(c),arrowLeftElement=d,arrowRightElement=e,currentElement=carouselElements[0];carouselContainer.clientWidth>getTotalWidthOfItems()||(carouselContainer.style="\n display:flex;\n justify-content: flex-start;\n flex-wrap:nowrap;\n overflow:hidden;",updateButtons(),arrowLeftElement.addEventListener("click",scrollToLeft),arrowRightElement.addEventListener("click",scrollToRight),carouselContainer.addEventListener("scroll",updateButtons))}function scrollToLeft(){carouselContainer.scroll({left:carouselContainer.scrollLeft-getWidthPlusPaddingAndMargin(currentElement),behavior:"smooth"}),backPointer()}function scrollToRight(){carouselContainer.scroll({left:carouselContainer.scrollLeft+getWidthPlusPaddingAndMargin(currentElement),behavior:"smooth"}),advancePointer()}function updateButtons(){arrowLeftElement.disabled=!1,arrowRightElement.disabled=!1,carouselContainer.scrollLeft?scrolledDistance()===carouselContainer.scrollWidth&&(arrowRightElement.disabled=!0):arrowLeftElement.disabled=!0}function advancePointer(){var a=carouselElements.indexOf(currentElement);a<carouselElements.length-1&&(currentElement=carouselElements[++a])}function backPointer(){var a=carouselElements.indexOf(currentElement);0<a&&(currentElement=carouselElements[--a])}function getTotalWidthOfItems(){return carouselElements.map(function(a){return a.clientWidth}).reduce(function(a,b){return a+b})}function scrolledDistance(){return carouselContainer.clientWidth+carouselContainer.scrollLeft}function getWidthPlusPaddingAndMargin(a){return parseInt(window.getComputedStyle(a).width)+parseInt(window.getComputedStyle(a).paddingLeft)+parseInt(window.getComputedStyle(a).paddingRight)+parseInt(window.getComputedStyle(a).marginLeft)+parseInt(window.getComputedStyle(a).marginRight)} |
{ | ||
"name": "carrossel", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "An agnostic framework carousel very easy to implement", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6027
80