I'm having problems with scroll-top
. The implemented function should take the input
that was with focus
it takes it to the top with scroll-top
, but it works satisfactorily only for the first clicks at the top of the page, and when I go down giving click it behaves unsatisfactorily instead of leading to the top of the page it leads to the bottom of the page. I have noticed that sometimes the value of position
is negative, but this is not always.
I tried to make sure that there was room for the field to roll up. So the problem is not in scrolling space.
Below is my code:
var tamanho = screen.height - 108 - 80;
var inputs = $('input').get();
$(inputs).on('focus', function () {
$(".ajusteTeclado").css("height", tamanho + "px");
$(".ajusteTeclado").show();
var pos = $(this).offset(),
position = pos.top - 60;
// positiohttp://pt.stackoverflow.com/q/108569/4995n = ((position < 0)? position * -1 : position);
console.log(position);
$(this).closest('.scrollPosition').scrollTop(position);
});
What could it be?
I need every time the field has been in focus it should be located at the top of the page.