Jump to content
Search Community

Consistent scaling when keyboard is visible on mobile device?

TheNomadicAspie test
Moderator Tag

Recommended Posts

I'm currently using an animation with scale: 8 to scale up a small image, and it works fine. This is how it looks.

mag1.thumb.png.2eeccc5c9ea09aa9fc535e9281d18806.png

 

The problem is, at some points this animation is called when a keyboard is visible, which seems to cause the image to scale relative to that half-sized image, and then get even larger. Here's what I mean. So this is what the app looks like prior to the animation being called.

mag2.thumb.png.6e9be9d0d5eb44485e5ae75fbb32a775.png

 

Then this happens when the app resizes once the keyboard moves away.

mag3.thumb.png.85928ce725b0a211dc729f899dbaa0fd.png

 

Is there a way to compensate for this?

Link to comment
Share on other sites

Unfortunately not. I created one

See the Pen NWaRyzo by TheNomadicAspie (@TheNomadicAspie) on CodePen

 but the behavior is different in CodePen. If you are typing in the input box and click the button, on CodePen it looks fine, but when I run it in my environment it becomes twice as large. I don't know if it's because of Parcel, my package bundler, or if it's something else... =/

 

Or maybe it's CodePen, because I noticed on CodePen my keyboard immediately shrinks before the animation plays, but in my environment the animation plays first, then the keyboard shrinks expanding the rest of the app, which causes the image to scale larger than it should.

Link to comment
Share on other sites

For now I used a hacky solution I found to detect if the keyboard is visible, and then I change the scale amount if so. It's not ideal, but it's working for now.

 

let full_window_height = window.innerHeight
let is_keyboard = false
let scale_amount

window.addEventListener('resize', () => {
	if (window.innerHeight === full_window_height) {
		is_keyboard = false
	} else {
		is_keyboard = true
	}
})


if (is_keyboard) {
	console.log("magnifyingGlassToCenter is_keyboard is true")
	scale_amount = 4
} else {
	console.log("magnifyingGlassToCenter is_keyboard is false")
	scale_amount = 8
}

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...