{"version":3,"sources":["webpack:///./handlers/postList.js","webpack:///./utils/utils.js"],"names":["$","jQuery","postList","postListWrapperEl","mediumMq","window","matchMedia","isRtlLang","document","dir","$wrapper","$itemContainer","find","$nextButton","$prevButton","items","children","currentItemIndex","renderPrevButton","addClass","removeClass","scrollToItem","item","anime","targets","duration","scrollLeft","offsetLeft","matches","easing","getNextItemData","length","getPrevItemData","on","nextItem","isInViewport","prevItem","sleep","ms","Promise","resolve","setTimeout","element","rect","getBoundingClientRect","top","left","bottom","innerHeight","documentElement","clientHeight","right","innerWidth","clientWidth","getCookie","name","cookieArr","cookie","split","i","cookiePair","trim","decodeURIComponent"],"mappings":";;;;;;;;;;AAAA;AAAA;AAAA;AAAA,IAAMA,CAAC,GAAGC,MAAV;AACA;AAEA;;AAGA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAACC,iBAAD,EAAuB;EACpC,IAAMC,QAAQ,GAAGC,MAAM,CAACC,UAAP,CAAkB,oBAAlB,CAAjB;EACA,IAAMC,SAAS,GAAGC,QAAQ,CAACC,GAAT,KAAiB,KAAnC;EAEA,IAAMC,QAAQ,GAAGV,CAAC,CAACG,iBAAD,CAAlB;EACA,IAAMQ,cAAc,GAAGD,QAAQ,CAACE,IAAT,CAAc,8BAAd,CAAvB;EAEA,IAAMC,WAAW,GAAGH,QAAQ,CAACE,IAAT,CAAcL,SAAS,GAAG,2BAAH,GAAiC,2BAAxD,CAApB;EACA,IAAMO,WAAW,GAAGJ,QAAQ,CAACE,IAAT,CAAcL,SAAS,GAAG,2BAAH,GAAiC,2BAAxD,CAApB;EACA,IAAMQ,KAAK,GAAGJ,cAAc,CAACK,QAAf,EAAd;EAEA,IAAIC,gBAAgB,GAAG,CAAvB;;EAEA,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,GAAM;IAC3BD,gBAAgB,KAAK,CAArB,GACMH,WAAW,CAACK,QAAZ,CAAqB,8BAArB,CADN,GAEML,WAAW,CAACM,WAAZ,CAAwB,8BAAxB,C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;EACH,CAJD;AAKH,CAlED;;AAoEelC,uEAAf,E;;;;;;;;;;;;AC1EA;AAAA;AAAA;AAAA;AAAA,SAASmC,KAAT,CAAeC,EAAf,EAAmB;EACf,OAAO,IAAIC,OAAJ,CAAY,UAAAC,OAAO;IAAA,OAAIC,UAAU,CAACD,OAAD,EAAUF,EAAV,CAAd;EAAA,CAAnB,CAAP;AACH;;AAED,SAASH,YAAT,CAAsBO,OAAtB,EAA+B;EAC3B,IAAMC,IAAI,GAAGD,OAAO,CAACE,qBAAR,EAAb;EAEA,OACID,IAAI,CAACE,GAAL,IAAY,CAAZ,IACAF,IAAI,CAACG,IAAL,IAAa,CADb,IAEAH,IAAI,CAACI,MAAL,KAAgB1C,MAAM,CAAC2C,WAAP,IAAsBxC,QAAQ,CAACyC,eAAT,CAAyBC,YAA/D,CAFA,IAGAP,IAAI,CAACQ,KAAL,KAAe9C,MAAM,CAAC+C,UAAP,IAAqB5C,QAAQ,CAACyC,eAAT,CAAyBI,WAA7D,CAJJ;AAMH;;AAED,SAASC,SAAT,CAAmBC,IAAnB,EAAyB;EACrB,IAAIC,SAAS,GAAGhD,QAAQ,CAACiD,MAAT,CAAgBC,KAAhB,CAAsB,GAAtB,CAAhB;;EAEA,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGH,SAAS,CAACzB,MAA9B,EAAsC4B,CAAC,EAAvC,EAA2C;IACvC,IAAIC,UAAU,GAAGJ,SAAS,CAACG,CAAD,CAAT,CAAaD,KAAb,CAAmB,GAAnB,CAAjB;;IAEA,IAAIH,IAAI,IAAIK,UAAU,CAAC,CAAD,CAAV,CAAcC,IAAd,EAAZ,EAAkC;MAC9B,OAAOC,kBAAkB,CAACF,UAAU,CAAC,CAAD,CAAX,CAAzB;IACH;EACJ;;EAED,OAAO,IAAP;AACH","file":"post-list.js","sourcesContent":["const $ = jQuery;\nimport anime from 'animejs/lib/anime.es.js';\n\nimport { isInViewport } from '../utils/utils'\n\n\nconst postList = (postListWrapperEl) => {\n const mediumMq = window.matchMedia('(max-width: 768px)');\n const isRtlLang = document.dir === 'rtl';\n\n const $wrapper = $(postListWrapperEl);\n const $itemContainer = $wrapper.find('.js-post-list-item-container');\n\n const $nextButton = $wrapper.find(isRtlLang ? '.js-post-list-button-prev' : '.js-post-list-button-next');\n const $prevButton = $wrapper.find(isRtlLang ? '.js-post-list-button-next' : '.js-post-list-button-prev');\n const items = $itemContainer.children();\n\n let currentItemIndex = 0;\n\n const renderPrevButton = () => {\n currentItemIndex === 0\n ? $prevButton.addClass('post-list__button--is-hidden')\n : $prevButton.removeClass('post-list__button--is-hidden');\n }\n\n renderPrevButton()\n\n const scrollToItem = (item) => {\n renderPrevButton();\n\n anime({\n targets: $itemContainer[0],\n duration: 300,\n scrollLeft: item.offsetLeft - (mediumMq.matches ? 30 : 24), //$itemContainer.offset().right,\n easing: 'easeInOutQuad'\n })\n };\n\n const getNextItemData = () => {\n currentItemIndex = (++currentItemIndex) % items.length;\n return items[currentItemIndex];\n };\n\n const getPrevItemData = () => {\n currentItemIndex = currentItemIndex === 0\n ? items.length - 1\n : --currentItemIndex;\n return items[currentItemIndex];\n };\n\n $($nextButton).on('click', () => {\n if(!isRtlLang) {\n const nextItem = getNextItemData();\n scrollToItem(nextItem);\n\n return;\n }\n\n let nextItem;\n\n do {\n nextItem = getNextItemData();\n } while(isInViewport(nextItem));\n\n scrollToItem(nextItem);\n });\n\n $($prevButton).on('click', () => {\n const prevItem = getPrevItemData();\n\n scrollToItem(prevItem);\n });\n};\n\nexport default postList;\n","function sleep(ms) {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\nfunction isInViewport(element) {\n const rect = element.getBoundingClientRect();\n\n return (\n rect.top >= 0 &&\n rect.left >= 0 &&\n rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&\n rect.right <= (window.innerWidth || document.documentElement.clientWidth)\n );\n}\n\nfunction getCookie(name) {\n let cookieArr = document.cookie.split(\";\");\n\n for (let i = 0; i < cookieArr.length; i++) {\n let cookiePair = cookieArr[i].split(\"=\");\n\n if (name == cookiePair[0].trim()) {\n return decodeURIComponent(cookiePair[1]);\n }\n }\n\n return null;\n}\n\nexport {\n sleep,\n isInViewport,\n getCookie\n};\n"],"sourceRoot":""}