UNPKG

swiper

Version:

Most modern mobile touch slider and framework with hardware accelerated transitions

2 lines 4.2 kB
function classesToTokens(e=""){return e.trim().split(" ").filter(e=>!!e.trim())}function deleteProps(e){Object.keys(e).forEach(t=>{try{e[t]=null}catch{}try{delete e[t]}catch{}})}function nextTick(e,t=0){return setTimeout(e,t)}function now(){return Date.now()}function getComputedStyle(e){return window.getComputedStyle(e,null)}function getTranslate(e,t="x"){const n=getComputedStyle(e),r=n.transform||n.webkitTransform;if(!r||"none"===r)return 0;const o=new DOMMatrixReadOnly(r);return"x"===t?o.m41:o.m42}function isObject(e){return"object"==typeof e&&null!==e&&e.constructor===Object&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function isNode(e){return"undefined"!=typeof HTMLElement&&e instanceof HTMLElement||!!e&&"object"==typeof e&&(1===e.nodeType||11===e.nodeType)}function extend(e,...t){const n=Object(e);for(let e=0;e<t.length;e+=1){const r=t[e];if(null==r||isNode(r))continue;const o=r,s=Object.keys(Object(o)).filter(e=>"__proto__"!==e&&"constructor"!==e&&"prototype"!==e);for(const e of s){const t=Object.getOwnPropertyDescriptor(o,e);if(!t||!t.enumerable)continue;const r=o[e];isObject(n[e])&&isObject(r)?r.__swiper__?n[e]=r:extend(n[e],r):!isObject(n[e])&&isObject(r)?(n[e]={},r.__swiper__?n[e]=r:extend(n[e],r)):n[e]=r}}return n}function setCSSProperty(e,t,n){e.style.setProperty(t,n)}function getSlideTransformEl(e){const t=e.querySelector(".swiper-slide-transform");if(t)return t;if(e.shadowRoot){const t=e.shadowRoot.querySelector(".swiper-slide-transform");if(t)return t}return e}function elementChildren(e,t=""){const n=[...e.children];return e instanceof HTMLSlotElement&&n.push(...e.assignedElements()),t?n.filter(e=>e.matches(t)):n}function elementIsChildOfSlot(e,t){const n=[t];for(;n.length>0;){const t=n.shift();if(e===t)return!0;n.push(...t.children,...t.shadowRoot?t.shadowRoot.children:[],...t.assignedElements?t.assignedElements():[])}return!1}function elementIsChildOf(e,t){let n=t.contains(e);if(!n&&t instanceof HTMLSlotElement){n=[...t.assignedElements()].includes(e),n||(n=elementIsChildOfSlot(e,t))}return n}function showWarning(e){try{console.warn(e)}catch{}}function createElement(e,t=[]){const n=document.createElement(e);return n.classList.add(...Array.isArray(t)?t:classesToTokens(t)),n}function elementOffset(e){const t=e.getBoundingClientRect();return{top:t.top+window.scrollY-(e.clientTop||0),left:t.left+window.scrollX-(e.clientLeft||0)}}function elementPrevAll(e,t){const n=[];let r=e.previousElementSibling;for(;r;)t&&!r.matches(t)||n.push(r),r=r.previousElementSibling;return n}function elementNextAll(e,t){const n=[];let r=e.nextElementSibling;for(;r;)t&&!r.matches(t)||n.push(r),r=r.nextElementSibling;return n}function elementStyle(e,t){return window.getComputedStyle(e,null).getPropertyValue(t)}function elementIndex(e){if(e&&e.parentNode)return[...e.parentNode.children].indexOf(e)}function elementParents(e,t){const n=[];let r=e.parentElement;for(;r;)t&&!r.matches(t)||n.push(r),r=r.parentElement;return n}function elementTransitionEnd(e,t){t&&e.addEventListener("transitionend",function(n){n.target===e&&t.call(e,n)},{once:!0})}function elementOuterSize(e,t,n){{const n=window.getComputedStyle(e,null);return e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(n.getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(n.getPropertyValue("width"===t?"margin-left":"margin-bottom"))}}function makeElementsArray(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}function getRotateFix(e){return t=>Math.abs(t)>0&&e.browser&&e.browser.need3dFix&&Math.abs(t)%90==0?t+.001:t}function setInnerHTML(e,t=""){const n=globalThis.trustedTypes;e.innerHTML=void 0!==n?n.createPolicy("html",{createHTML:e=>e}).createHTML(t):t}export{createElement as a,elementIndex as b,classesToTokens as c,deleteProps as d,elementChildren as e,elementIsChildOf as f,elementNextAll as g,elementOffset as h,elementOuterSize as i,elementParents as j,elementPrevAll as k,elementStyle as l,elementTransitionEnd as m,extend as n,getRotateFix as o,getSlideTransformEl as p,getTranslate as q,isObject as r,makeElementsArray as s,nextTick as t,now as u,setCSSProperty as v,setInnerHTML as w,showWarning as x}; //# sourceMappingURL=utils.min.mjs.map