1/******/ (function() { // webpackBootstrap 2/******/ // runtime can't be in strict mode because a global variable is assign and maybe created. 3/******/ // The require scope 4/******/ var __webpack_require__ = {}; 5/******/ 6/************************************************************************/ 7/******/ /* webpack/runtime/define property getters */ 8/******/ !function() { 9/******/ // define getter functions for harmony exports 10/******/ __webpack_require__.d = function(exports, definition) { 11/******/ for(var key in definition) { 12/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 13/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 14/******/ } 15/******/ } 16/******/ }; 17/******/ }(); 18/******/ 19/******/ /* webpack/runtime/hasOwnProperty shorthand */ 20/******/ !function() { 21/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } 22/******/ }(); 23/******/ 24/******/ /* webpack/runtime/make namespace object */ 25/******/ !function() { 26/******/ // define __esModule on exports 27/******/ __webpack_require__.r = function(exports) { 28/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 29/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 30/******/ } 31/******/ Object.defineProperty(exports, '__esModule', { value: true }); 32/******/ }; 33/******/ }(); 34/******/ 35/************************************************************************/ 36var __webpack_exports__ = {}; 37// This entry need to be wrapped in an IIFE because it need to be in strict mode. 38!function() { 39"use strict"; 40/*!********************************************************!*\ 41 !*** ./block-editor/blocks/card-slider/view-script.js ***! 42 \********************************************************/ 43__webpack_require__.r(__webpack_exports__); 44/* harmony export */ __webpack_require__.d(__webpack_exports__, { 45/* harmony export */ Slider: function() { return /* binding */ Slider; } 46/* harmony export */ }); 47class Slider { 48 /** 49 * Initialize a new Sections element 50 * 51 * @param {HTMLElement} node - the node that contains the root scrolling element 52 * @param {object} opts - 53 */ 54 constructor(node, opts) { 55 this.node = node; 56 this.opts = { 57 back: '.card-slider__nav-btn--prev', 58 forward: '.card-slider__nav-btn--next', 59 content: '.card-slider__content', 60 items: '.card-slider__content > *', 61 sticky: true, 62 ...opts 63 }; 64 if (!this.node) { 65 return; 66 } 67 this.interval = null; 68 this.back = this.node.querySelector(this.opts.back); 69 this.forward = this.node.querySelector(this.opts.forward); 70 this.content = this.node.querySelector(this.opts.content); 71 this.items = this.node.querySelectorAll(this.opts.items); 72 window.addEventListener('resize', this.setState.bind(this)); 73 this.content.addEventListener('scroll', this.setState.bind(this)); 74 this.forward.addEventListener('click', this.forwardIndex.bind(this)); 75 this.back.addEventListener('click', this.backIndex.bind(this)); 76 this.setIndex(0); 77 this.setState(); 78 } 79 80 /** 81 * Scroll forward the scrollable content area 82 */ 83 scrollForward() { 84 this.scrollInterval = setInterval(() => { 85 this.content.scrollTo({ 86 left: this.content.scrollLeft + 5 87 }); 88 if (this.forward.disabled) { 89 this.scrollStop(); 90 } 91 }, 10); 92 } 93 94 /** 95 * Scroll backwards the scrollable content area 96 */ 97 scrollBack() { 98 this.scrollInterval = setInterval(() => { 99 this.content.scrollTo({ 100 left: Math.max(0, this.content.scrollLeft - 5) 101 }); 102 if (this.back.disabled) { 103 this.scrollStop(); 104 } 105 }, 10); 106 } 107 108 /** 109 * Stop the scrolling interval if it's active 110 */ 111 scrollStop() { 112 if (typeof this.scrollInterval === 'number') { 113 clearInterval(this.scrollInterval); 114 } 115 this.scrollInterval = null; 116 } 117 setState() { 118 const firstItem = this.items[0]; 119 const lastItem = this.items[this.items.length - 1]; 120 if (firstItem.offsetLeft - this.content.scrollLeft >= 0) { 121 // first item is is view 122 this.back.disabled = true; 123 } else { 124 // first item is outside the scroll area 125 this.back.removeAttribute('disabled'); 126 } 127 if (this.content.scrollLeft + this.content.offsetWidth >= lastItem.offsetLeft + lastItem.offsetWidth - 1) { 128 // the last item is fully in view 129 this.forward.disabled = true; 130 } else { 131 // last item is outside the scroll area 132 this.forward.removeAttribute('disabled'); 133 } 134 } 135 getIndex() { 136 const offset = this.getPaddingOffset(); 137 const distances = [...this.items].map(item => Math.abs(item.offsetLeft - this.content.scrollLeft - offset)); 138 return distances.indexOf(Math.min(...distances)); 139 } 140 getPaddingOffset() { 141 return Math.max(parseInt(getComputedStyle(this.content).paddingLeft, 10), 0); 142 } 143 setIndex(index) { 144 let behavior = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'smooth'; 145 if (index <= this.items.length) { 146 const left = this.items[index].offsetLeft - this.getPaddingOffset(); 147 this.content.scrollTo({ 148 left: Math.max(0, left), 149 behavior 150 }); 151 } else if (interval > 0) { 152 clearInterval(interval); 153 interval = null; 154 } 155 } 156 backIndex() { 157 this.setIndex(Math.round(Math.max(this.getIndex() - 1, 0))); 158 } 159 forwardIndex() { 160 this.setIndex(Math.round(Math.min(this.getIndex() + 1, this.items.length - 1))); 161 } 162} 163document.addEventListener('DOMContentLoaded', () => { 164 document.querySelectorAll('.card-slider').forEach(node => { 165 new Slider(node, { 166 ...node.dataset 167 }); 168 }); 169}); 170}(); 171var __webpack_export_target__ = (wdg.blocks.cardSliderViewScript = typeof wdg.blocks.cardSliderViewScript === "undefined" ? {} : wdg.blocks.cardSliderViewScript); 172for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
173if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true }); 174/******/ })() 175; 176//# sourceMappingURL=view-script.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.