1//import Debounce from "../Debounce/debounce.min.js"; 2class BackgroundFocus { 3 constructor(e, t) { 4 this.container = e, 5 this.options = t, 6 this.isFixed = !1, 7 this.boundingClientRect = null, 8 this.initialize() 9 } 10 initialize() { 11 "interactive" === document.readyState || "complete" === document.readyState || "loaded" === document.readyState ? (this.updateFocusAreaByMediaCondition(), 12 this.updateContainerBackgroundPosition()) : document.onreadystatechange = () => { 13 "interactive" !== document.readyState && "complete" !== document.readyState && "loaded" !== document.readyState || (this.updateFocusAreaByMediaCondition(), 14 this.updateContainerBackgroundPosition()) 15 } 16 } 17 updateContainerBackgroundPosition() { 18 this.isFixed = "fixed" === getComputedStyle(this.container).backgroundAttachment, 19 this.boundingClientRect = this.container.getBoundingClientRect(); 20 const e = this.getContainerBounds() 21 , t = this.calcBackgroundImageCoverSize(e, this.focusArea.iw, this.focusArea.ih) 22 , i = this.isFixed ? Math.floor(this.boundingClientRect.left) : 0 23 , o = -1 * (t.width - e.width) 24 , n = -1 * (t.height - e.height) 25 , s = { 26 x: t.width * this.focusArea.x * -1 - t.width * this.focusArea.fw / 2 + e.width / 2, 27 y: t.height * this.focusArea.y * -1 - t.height * this.focusArea.fh / 2 + e.height / 2 28 }; 29 s.x = this.range(s.x, o, i), 30 s.y = this.range(s.y, n, 0), 31 this.container.style.backgroundPosition = s.x + "px " + s.y + "px" 32 } 33 getContainerBounds() { 34 return this.isFixed ? { 35 width: window.innerWidth, 36 height: window.innerHeight 37 } : this.boundingClientRect 38 } 39 range(e, t, i) { 40 return e < t ? t : e > i ? i : e 41 } 42 calcBackgroundImageCoverSize(e, t, i) { 43 const o = [] 44 , n = this.isFixed ? window.innerWidth : e.width 45 , s = this.isFixed ? window.innerHeight : e.height; 46 return 100 / n * (n - t) * -1 < 100 / s * (s - i) * -1 ? (o.width = n, 47 o.height = i - i / t * (-1 * (n - t))) : (o.height = s, 48 o.width = t - t / i * (-1 * (s - i))), 49 o 50 } 51 updateFocusAreaByMediaCondition() { 52 this.focusArea = !1; 53 for (let e in this.options) 54 if (this.options.hasOwnProperty(e)) { 55 const t = window.matchMedia(e); 56 if ((t && t.matches || "default" === e) && (this.focusArea = this.options[e], 57 "default" !== e)) 58 break 59 } 60 return this.focusArea 61 } 62 static observe(e, t) { 63 if (!e || !t || "cover" !== getComputedStyle(e).backgroundSize || -1 !== BackgroundFocus.containers.indexOf(e)) 64 return; 65 const i = new this(e,t); 66 return BackgroundFocus.observables.push(i), 67 BackgroundFocus.containers.push(e), 68 BackgroundFocus.observes || (BackgroundFocus.observes = !0, 69 window.addEventListener("resize", Debounce.debounce( () => { 70 for (let e = 0; e < BackgroundFocus.observables.length; e++) 71 BackgroundFocus.observables[e].updateContainerBackgroundPosition() 72 } 73 , 500))), 74 i 75 } 76} 77BackgroundFocus.observes = !1, 78BackgroundFocus.observables = [], 79BackgroundFocus.containers = []; 80//const BackgroundFocus = new BackgroundFocus();
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.