Skip to content

Commit

Permalink
Merge branch 'release/v0.24.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
holtwick committed Oct 27, 2024
2 parents a007d58 + 73a2903 commit 3eb1a3e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 61 deletions.
111 changes: 61 additions & 50 deletions lib/mobile/oui-mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,73 +22,84 @@ const keyboardAnimationDuration = 400
if (useSingleton('oui-mobile')) {
log('init')
if (window.visualViewport != null) {
let timer: any
let virtualKeyboardActive = false
async function resizeHandler() {
// Adjust the height!
const height = `${window.visualViewport?.height.toString()}px`
log(`resize height=${height}`)
// document.documentElement.style.height = `${window.visualViewport?.height.toString()}px`
document.documentElement.style.setProperty('--visible-height', height)
await nextTick()
// Try to guess, if the virtual keyboard did show up
// https://stackoverflow.com/questions/497094/how-do-i-find-out-which-dom-element-has-the-focus
virtualKeyboardActive = document.activeElement?.matches('input,textarea,[contenteditable]') ?? false
if (virtualKeyboardActive) {
document.documentElement.classList.add('virtual-keyboard')
clearTimeout(timer)
// With some delay scroll active/focussed element into view
timer = setTimeout(() => {
if (document.activeElement?.matches('input,textarea,[contenteditable]')) {
log('scroll into view', document.activeElement)
document.activeElement?.scrollIntoView({
// behavior: 'smooth',
behavior: 'instant',
block: 'nearest',
inline: 'nearest',
})
}
}, keyboardAnimationDuration)
try {
// Adjust the height!
const height = `${window.visualViewport?.height.toString()}px`
log(`resize height=${height}`)
// document.documentElement.style.height = `${window.visualViewport?.height.toString()}px`
document.documentElement.style.setProperty('--visible-height', height)
await nextTick()
// Try to guess, if the virtual keyboard did show up
// https://stackoverflow.com/questions/497094/how-do-i-find-out-which-dom-element-has-the-focus
virtualKeyboardActive = document.activeElement?.matches('input,textarea,[contenteditable]') ?? false
if (virtualKeyboardActive) {
document.documentElement.classList.add('virtual-keyboard')
clearTimeout(timer)
// With some delay scroll active/focussed element into view
timer = setTimeout(() => {
if (document.activeElement?.matches('input,textarea,[contenteditable]')) {
log('scroll into view', document.activeElement)
document.activeElement?.scrollIntoView({
// behavior: 'smooth',
behavior: 'instant',
block: 'nearest',
inline: 'nearest',
})
}
}, keyboardAnimationDuration)
}
else {
document.documentElement.classList.remove('virtual-keyboard')
}
}
else {
document.documentElement.classList.remove('virtual-keyboard')
catch (err) {
log.error('resizeHandler issue', err)
}
}
useEventListener(window.visualViewport, 'resize', resizeHandler)
useEventListener(window.visualViewport, 'scroll', resizeHandler)
try {
useEventListener(window.visualViewport, 'resize', resizeHandler)
useEventListener(window.visualViewport, 'scroll', resizeHandler)
// if (props.mode === 'app') {
// Intercept `touchmove` where no scrolling is planned in our UI
useEventListener(window, 'touchmove', (ev) => {
log('touch move', ev.target)
// if (props.mode === 'app') {
// Intercept `touchmove` where no scrolling is planned in our UI
useEventListener(window, 'touchmove', (ev) => {
log('touch move', ev.target)
// if (virtualKeyboardActive === false)
// return
// if (virtualKeyboardActive === false)
// return
if (isInsideScrollable(ev.target as any))
return
if (isInsideScrollable(ev.target as any))
return
log('prevent scroll')
// If not avoid scrolling
ev.preventDefault()
log('prevent scroll')
// If not avoid scrolling
ev.preventDefault()
// ev.stopPropagation()
}, {
}, {
// make sure, we get those events
passive: false,
// capture them as early as possible
capture: true,
})
// }
passive: false,
// capture them as early as possible
capture: true,
})
// }
onMounted(resizeHandler)
onMounted(resizeHandler)
}
catch (err) {
log.error('init issue', err)
}
}
onMounted(() => document.documentElement.classList.add('oui-mobile'))
}
</script>
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "oui-kit",
"type": "module",
"version": "0.24.1",
"version": "0.24.2",
"author": {
"email": "[email protected]",
"name": "Dirk Holtwick",
Expand Down Expand Up @@ -75,23 +75,23 @@
"dependencies": {
"@floating-ui/vue": "^1.1.5",
"@vueuse/core": "^11.1.0",
"vue": "^3.5.11",
"zeed": "^0.24.22"
"vue": "^3.5.12",
"zeed": "^0.25.4"
},
"devDependencies": {
"@antfu/eslint-config": "^3.7",
"@antfu/eslint-config": "^3.8",
"@antfu/ni": "^0.23.0",
"@shikijs/markdown-it": "^1.21.0",
"@shikijs/markdown-it": "^1.22.1",
"@vitejs/plugin-vue": "^5.1.4",
"@vitest/browser": "^2.1.2",
"@vitest/browser": "^2.1.3",
"eslint": "^9",
"stylus": "^0.63.0",
"tsup": "^8.3.0",
"stylus": "^0.64.0",
"tsup": "^8.3.5",
"typescript": "^5.6",
"unplugin-vue-markdown": "^0.26.2",
"vite": "^5.4.8",
"vite-plugin-dts": "^4.2.3",
"vite": "^5.4.10",
"vite-plugin-dts": "^4.3.0",
"vite-plugin-qrcode": "^0.2.3",
"vitest": "^2.1.2"
"vitest": "^2.1.3"
}
}

0 comments on commit 3eb1a3e

Please sign in to comment.