Framework7: Auto Scroll page-content to keep input always visible when Keyboard is displayed

Created on 2 Oct 2016  ·  11Comments  ·  Source: framework7io/framework7

This is a (multiple allowed):

  • [ ] bug
  • [X] enhancement
  • [ ] feature-discussion (RFC)
  • Framework7 Version: V1.4.2
  • Platform and Target: Android AND IOS.

There is currently a problem when the user clicks on an input at the bottom of the screen. The keyboard gets displayed but it covers the input that the user clicked on. Only when the user starts typing on the keyboard, the input automatically scrolls up and becomes visible above the keyboard.

It would be nice to have Framework7 automatically handles this issue for all users in a similar way to that of the Ionic framework. With Ionic, a specific keyboard plugin is used.
https://github.com/driftyco/ionic-plugin-keyboard
After installing the plugin, the Ionic framework automatically handles the scrolling for inputs which are at the bottom of the screen.

Enhancement Feature Request

Most helpful comment

@bhumin3i @JosephShenton @imac8t @seme1

Here my work around (call it after the fields have been loaded):

_if (!myApp.device.ios) {
$$(page.container).find('input, textarea').on('focus', function (event) {
var container = $$(event.target).closest('.page-content');
var elementOffset = $$(event.target).offset().top;
var pageOffset = container.scrollTop();
var newPageOffset = pageOffset + elementOffset - 81;
setTimeout(function () {
container.scrollTop(newPageOffset, 300);
}, 700);
});
}_

All 11 comments

i have this problem now

I used this jQuery plugin to automatically scroll to any input by listening to input onFocus events.
https://github.com/flesler/jquery.scrollTo

This has solved all the problems I faced without the need to use the keyboard plugin. The scrollTo plugin attempts to keep the focused input always near the top of the screen. It would be nice if Framework7 has integrated such a function within (or has the option of enabling/disabling this function by simply adding a certain class name to any input).

Yeah please make that!!!

That would be easy but I have no idea how to make a pull request lol

Fork the repository, code and do a pull request :)

Ok when I get home I'll do it

hey help me out i'm stuck,
give me some example

@bhumin3i @JosephShenton @imac8t @seme1

Here my work around (call it after the fields have been loaded):

_if (!myApp.device.ios) {
$$(page.container).find('input, textarea').on('focus', function (event) {
var container = $$(event.target).closest('.page-content');
var elementOffset = $$(event.target).offset().top;
var pageOffset = container.scrollTop();
var newPageOffset = pageOffset + elementOffset - 81;
setTimeout(function () {
container.scrollTop(newPageOffset, 300);
}, 700);
});
}_

@seme1 could you like to share your code that using JQuery.scrollTo. i have some little confusing to using it

Issue is closed because of outdated/irrelevant/not actual

If this issue is still actual and reproducible for latest version of Framework7, please create new issue and fill the issue template correctly:

  • Clearly describe the issue including steps to reproduce when it is a bug.
  • Make sure you fill in the earliest version that you know has the issue.
  • Provide live link or JSFiddle/Codepen or website with issue
Was this page helpful?
0 / 5 - 0 ratings

Related issues

l2aelba picture l2aelba  ·  4Comments

M4ttscx picture M4ttscx  ·  4Comments

vousys picture vousys  ·  4Comments

ahmeddaif1 picture ahmeddaif1  ·  4Comments

yeli19950109 picture yeli19950109  ·  3Comments