Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting when native select widget is opened/closed in UIWebView

When the user clicks on a select box in UIWebView, a native popover is displayed at the bottom of the screen with the available options. The webpage contents scroll up to make room for this popover.

It seems like no DOM event is fired when this scroll happens, although the value of body.scrollTop does change. Is there any way to detect when the popover is opened, or do we have to use setInterval to poll and watch for scrollTop changing?

like image 635
Matthew Gertner Avatar asked Jun 05 '15 16:06

Matthew Gertner


1 Answers

I'm surprised that the scroll event isn't firing. MDN has a list of events that can be bound to that might be of help to you.

A quick thought that jumps out to me is that you could bind to the mouseup and input/change events on the select and in their callbacks determine what the scrollTop is as the user interacts with the select. If you have multiple selects you need to track, you could delegate the events to the body to avoid creating additional listeners.

Polling would work, but it'd be a lot less efficient then adding a few event listeners on the select itself, so hopefully you can find an event that works.

Hope that helps!

like image 95
Benjamin Solum Avatar answered Oct 29 '22 22:10

Benjamin Solum