You've already forked AstralRinth
forked from didirus/AstralRinth
Bump tauri to v2 (#3018)
* Bump tauri to v2 * Switch to virtual typed list for content page * Fix unexpected hang on windows * Fix ads window scaling issues on some devices * Use DPR from browser * Fix link opens, bump version, fix lint
This commit is contained in:
@@ -4,20 +4,29 @@ import { ChevronRightIcon } from '@modrinth/assets'
|
||||
import { init_ads_window, open_ads_link, record_ads_click } from '@/helpers/ads.js'
|
||||
|
||||
const adsWrapper = ref(null)
|
||||
|
||||
let devicePixelRatioWatcher = null
|
||||
|
||||
function initDevicePixelRatioWatcher() {
|
||||
if (devicePixelRatioWatcher) {
|
||||
devicePixelRatioWatcher.removeEventListener('change', updateAdPosition)
|
||||
}
|
||||
|
||||
devicePixelRatioWatcher = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)
|
||||
devicePixelRatioWatcher.addEventListener('change', updateAdPosition)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
updateAdPosition()
|
||||
|
||||
window.addEventListener('resize', updateAdPosition)
|
||||
initDevicePixelRatioWatcher()
|
||||
})
|
||||
|
||||
function updateAdPosition() {
|
||||
if (adsWrapper.value) {
|
||||
const rect = adsWrapper.value.getBoundingClientRect()
|
||||
|
||||
const x = rect.left + window.scrollX
|
||||
const y = rect.top + window.scrollY
|
||||
|
||||
init_ads_window(x, y, 300, 250, true)
|
||||
init_ads_window(true)
|
||||
initDevicePixelRatioWatcher()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user