bahar.wadia
Posts: 0
Joined: Wed Aug 07, 2013 2:05 am

How to scroll screen to the top of an element?

I have a CollapsibleSet. When the user clicks on a CollapsibleBlock that is toward the bottom of the screen, I want the screen to scroll up, so that the top of the CollapsibleBlock is at the top of the screen.

How do I do this?

I have tried the following ...

Code: Select all

 CollapsibleSelected.scrollIntoView(true); 

where CollapsibleSelected is the selected CollapsibleBlock.

I get the following error...

Uncaught TypeError: undefined is not a function VM4372355:540
onCollapsibleexpand VM4372355:540
jQuery.event.dispatch jquery-1.9.1.js:3074
jQuery.event.add.elemData.handle jquery-1.9.1.js:2750
jQuery.event.trigger jquery-1.9.1.js:2986
(anonymous function) jquery-1.9.1.js:3677
jQuery.extend.each jquery-1.9.1.js:648
jQuery.fn.jQuery.each jquery-1.9.1.js:270
jQuery.fn.extend.trigger jquery-1.9.1.js:3676
$.Widget.trigger jquery.mobile-1.4.0.js:1273
$.widget.handleExpandCollapse jquery.mobile-1.4.0.js:6798
(anonymous function) jquery.mobile-1.4.0.js:889
$.widget.create.on.click jquery.mobile-1.4.0.js:6588
handlerProxy jquery.mobile-1.4.0.js:1192
jQuery.event.dispatch jquery-1.9.1.js:3074
jQuery.event.add.elemData.handle

Thanks.

bahar.wadia
Posts: 0
Joined: Wed Aug 07, 2013 2:05 am

How to scroll screen to the top of an element?

That works nicely.

Thank you!

Beej
Posts: 0
Joined: Tue Jul 01, 2014 1:56 am

How to scroll screen to the top of an element?

This is working for me (and it scrolls more elegantly):
pre
$('html, body').animate({
scrollTop: Appery('my_element').offset().top
}, 800);
/pre

Return to “Issues”