this.shadowRoot.appendChild(linkElement) | this.shadowRoot.appendChild(linkElement) | ||||
} | } | ||||
#computeDimensions(mapContainer) { | |||||
// There has to be a better way but I feel lazy tonight. | |||||
let height = this.dataset.height | |||||
let width = this.dataset.width | |||||
// Size is in px so we strip these chars and convert to int. | |||||
const heightValue = Number(height.slice(0, -2)) | |||||
const widthValue = Number(width.slice(0, -2)) | |||||
const mediaQueryMiddle = window.matchMedia(`(max-width: ${widthValue}px)`) | |||||
const mediaQuerySmall = window.matchMedia(`(max-width: ${widthValue / 2}px)`) | |||||
if (mediaQueryMiddle.matches) { | |||||
height = `${heightValue / 2}px` | |||||
width = `${widthValue / 2}px` | |||||
} | |||||
if (mediaQuerySmall.matches) { | |||||
height = `${heightValue / 3}px` | |||||
width = `${widthValue / 3}px` | |||||
} | |||||
mapContainer.style.height = height | |||||
mapContainer.style.width = width | |||||
} | |||||
#createMapContainer() { | #createMapContainer() { | ||||
const mapContainer = document.createElement('div') | const mapContainer = document.createElement('div') | ||||
mapContainer.style.height = this.dataset.height | |||||
mapContainer.style.width = this.dataset.width | |||||
this.#computeDimensions(mapContainer) | |||||
this.shadowRoot.appendChild(mapContainer) | this.shadowRoot.appendChild(mapContainer) | ||||
return mapContainer | return mapContainer | ||||
} | } |
this.shadowRoot.appendChild(linkElement) | this.shadowRoot.appendChild(linkElement) | ||||
} | } | ||||
#computeDimensions(mapContainer) { | |||||
// There has to be a better way but I feel lazy tonight. | |||||
let height = this.dataset.height | |||||
let width = this.dataset.width | |||||
// Size is in px so we strip these chars and convert to int. | |||||
const heightValue = Number(height.slice(0, -2)) | |||||
const widthValue = Number(width.slice(0, -2)) | |||||
const mediaQueryMiddle = window.matchMedia(`(max-width: ${widthValue}px)`) | |||||
const mediaQuerySmall = window.matchMedia(`(max-width: ${widthValue / 2}px)`) | |||||
if (mediaQueryMiddle.matches) { | |||||
height = `${heightValue / 2}px` | |||||
width = `${widthValue / 2}px` | |||||
} | |||||
if (mediaQuerySmall.matches) { | |||||
height = `${heightValue / 3}px` | |||||
width = `${widthValue / 3}px` | |||||
} | |||||
mapContainer.style.height = height | |||||
mapContainer.style.width = width | |||||
} | |||||
#createMapContainer() { | #createMapContainer() { | ||||
const mapContainer = document.createElement('div') | const mapContainer = document.createElement('div') | ||||
mapContainer.style.height = this.dataset.height | |||||
mapContainer.style.width = this.dataset.width | |||||
this.#computeDimensions(mapContainer) | |||||
this.shadowRoot.appendChild(mapContainer) | this.shadowRoot.appendChild(mapContainer) | ||||
return mapContainer | return mapContainer | ||||
} | } |
this.shadowRoot.appendChild(linkElement) | this.shadowRoot.appendChild(linkElement) | ||||
} | } | ||||
#computeDimensions(mapContainer) { | |||||
// There has to be a better way but I feel lazy tonight. | |||||
let height = this.dataset.height | |||||
let width = this.dataset.width | |||||
// Size is in px so we strip these chars and convert to int. | |||||
const heightValue = Number(height.slice(0, -2)) | |||||
const widthValue = Number(width.slice(0, -2)) | |||||
const mediaQueryMiddle = window.matchMedia(`(max-width: ${widthValue}px)`) | |||||
const mediaQuerySmall = window.matchMedia(`(max-width: ${widthValue / 2}px)`) | |||||
if (mediaQueryMiddle.matches) { | |||||
height = `${heightValue / 2}px` | |||||
width = `${widthValue / 2}px` | |||||
} | |||||
if (mediaQuerySmall.matches) { | |||||
height = `${heightValue / 3}px` | |||||
width = `${widthValue / 3}px` | |||||
} | |||||
mapContainer.style.height = height | |||||
mapContainer.style.width = width | |||||
} | |||||
#createMapContainer() { | #createMapContainer() { | ||||
const mapContainer = document.createElement('div') | const mapContainer = document.createElement('div') | ||||
mapContainer.style.height = this.dataset.height | |||||
mapContainer.style.width = this.dataset.width | |||||
this.#computeDimensions(mapContainer) | |||||
this.shadowRoot.appendChild(mapContainer) | this.shadowRoot.appendChild(mapContainer) | ||||
return mapContainer | return mapContainer | ||||
} | } |
this.shadowRoot.appendChild(linkElement) | this.shadowRoot.appendChild(linkElement) | ||||
} | } | ||||
#computeDimensions(mapContainer) { | |||||
// There has to be a better way but I feel lazy tonight. | |||||
let height = this.dataset.height | |||||
let width = this.dataset.width | |||||
// Size is in px so we strip these chars and convert to int. | |||||
const heightValue = Number(height.slice(0, -2)) | |||||
const widthValue = Number(width.slice(0, -2)) | |||||
const mediaQueryMiddle = window.matchMedia(`(max-width: ${widthValue}px)`) | |||||
const mediaQuerySmall = window.matchMedia(`(max-width: ${widthValue / 2}px)`) | |||||
if (mediaQueryMiddle.matches) { | |||||
height = `${heightValue / 2}px` | |||||
width = `${widthValue / 2}px` | |||||
} | |||||
if (mediaQuerySmall.matches) { | |||||
height = `${heightValue / 3}px` | |||||
width = `${widthValue / 3}px` | |||||
} | |||||
mapContainer.style.height = height | |||||
mapContainer.style.width = width | |||||
} | |||||
#createMapContainer() { | #createMapContainer() { | ||||
const mapContainer = document.createElement('div') | const mapContainer = document.createElement('div') | ||||
mapContainer.style.height = this.dataset.height | |||||
mapContainer.style.width = this.dataset.width | |||||
this.#computeDimensions(mapContainer) | |||||
this.shadowRoot.appendChild(mapContainer) | this.shadowRoot.appendChild(mapContainer) | ||||
return mapContainer | return mapContainer | ||||
} | } |
this.shadowRoot.appendChild(linkElement) | this.shadowRoot.appendChild(linkElement) | ||||
} | } | ||||
#computeDimensions(mapContainer) { | |||||
// There has to be a better way but I feel lazy tonight. | |||||
let height = this.dataset.height | |||||
let width = this.dataset.width | |||||
// Size is in px so we strip these chars and convert to int. | |||||
const heightValue = Number(height.slice(0, -2)) | |||||
const widthValue = Number(width.slice(0, -2)) | |||||
const mediaQueryMiddle = window.matchMedia(`(max-width: ${widthValue}px)`) | |||||
const mediaQuerySmall = window.matchMedia(`(max-width: ${widthValue / 2}px)`) | |||||
if (mediaQueryMiddle.matches) { | |||||
height = `${heightValue / 2}px` | |||||
width = `${widthValue / 2}px` | |||||
} | |||||
if (mediaQuerySmall.matches) { | |||||
height = `${heightValue / 3}px` | |||||
width = `${widthValue / 3}px` | |||||
} | |||||
mapContainer.style.height = height | |||||
mapContainer.style.width = width | |||||
} | |||||
#createMapContainer() { | #createMapContainer() { | ||||
const mapContainer = document.createElement('div') | const mapContainer = document.createElement('div') | ||||
mapContainer.style.height = this.dataset.height | |||||
mapContainer.style.width = this.dataset.width | |||||
this.#computeDimensions(mapContainer) | |||||
this.shadowRoot.appendChild(mapContainer) | this.shadowRoot.appendChild(mapContainer) | ||||
return mapContainer | return mapContainer | ||||
} | } |
<link href="https://larlet.fr/david/" rel="alternate" type="text/html" /> | <link href="https://larlet.fr/david/" rel="alternate" type="text/html" /> | ||||
<link href="https://larlet.fr/david/log/" rel="self" /> | <link href="https://larlet.fr/david/log/" rel="self" /> | ||||
<id>https://larlet.fr/david/</id> | <id>https://larlet.fr/david/</id> | ||||
<updated>2024-03-26T12:00:00+01:00</updated> | |||||
<updated>2024-03-27T12:00:00+01:00</updated> | |||||
<author> | <author> | ||||
<name>David Larlet</name> | <name>David Larlet</name> | ||||
<uri>https://larlet.fr/david/</uri> | <uri>https://larlet.fr/david/</uri> | ||||
this.shadowRoot.appendChild(linkElement) | this.shadowRoot.appendChild(linkElement) | ||||
} | } | ||||
#computeDimensions(mapContainer) { | |||||
// There has to be a better way but I feel lazy tonight. | |||||
let height = this.dataset.height | |||||
let width = this.dataset.width | |||||
// Size is in px so we strip these chars and convert to int. | |||||
const heightValue = Number(height.slice(0, -2)) | |||||
const widthValue = Number(width.slice(0, -2)) | |||||
const mediaQueryMiddle = window.matchMedia(`(max-width: ${widthValue}px)`) | |||||
const mediaQuerySmall = window.matchMedia(`(max-width: ${widthValue / 2}px)`) | |||||
if (mediaQueryMiddle.matches) { | |||||
height = `${heightValue / 2}px` | |||||
width = `${widthValue / 2}px` | |||||
} | |||||
if (mediaQuerySmall.matches) { | |||||
height = `${heightValue / 3}px` | |||||
width = `${widthValue / 3}px` | |||||
} | |||||
mapContainer.style.height = height | |||||
mapContainer.style.width = width | |||||
} | |||||
#createMapContainer() { | #createMapContainer() { | ||||
const mapContainer = document.createElement('div') | const mapContainer = document.createElement('div') | ||||
mapContainer.style.height = this.dataset.height | |||||
mapContainer.style.width = this.dataset.width | |||||
this.#computeDimensions(mapContainer) | |||||
this.shadowRoot.appendChild(mapContainer) | this.shadowRoot.appendChild(mapContainer) | ||||
return mapContainer | return mapContainer | ||||
} | } |