Ionic solution to keyboard blocking input box in developing iOS system micro-mail (keyboard eject problem) _javascript tips

Source: Internet
Author: User

When using ionic to develop iOS system micro-letter will have a problem, filling out the form when the keyboard will block the input box, in fact, is not a big problem, as long as the user input a word can immediately see the input box.

Unfortunately, some customers are unreasonable, he did not care about the problem, anyway, is not, so in a day of sleep suddenly awakened, think out this scheme.

I'm not going to go into the code, directly above.

Angular.module (' MyApp ')
. Directive (' focusinput ', [' $ionicScrollDelegate ', ' $window ', ' $timeout ', ' $ Ionicposition ', function ($ionicScrollDelegate, $window, $timeout, $ionicPosition) {return
{
restrict: ' A ',
Scope:false,
link:function ($scope, IELM, Iattrs, controller) {
if (ionic). Platform.isios ()) {
Ielm.on ("Focus", function () {
var top = $ionicScrollDelegate. GetScrollPosition ().
var eletop = ($ionicPosition. Offset (IELM). Top)/2
var realtop = eletop + top;
$timeout (function () {
if (! $scope. $last) {
$ionicScrollDelegate. Scrollto (0,realtop);
} else {
try {
var aim = angular.element (document). Find ('. Scroll ')
aim.css (' transform ', ' translate3d (0px, ' + '-' + Realtop + ' px, 0px] scale (1) ');
$timeout (function () {
ielm[0].focus ();
Console.log (2);
}, "
catch (E) {}}}}}}}}
]"
)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.