Page 1 of 1

How to scroll screen to the top of an element?

Posted: Sat Jul 12, 2014 10:30 pm
by bahar.wadia

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.


How to scroll screen to the top of an element?

Posted: Sun Jul 13, 2014 6:03 am
by Alena Prykhodko

Hello,

Please look at a similar post https://getsatisfaction.com/apperyio/...


How to scroll screen to the top of an element?

Posted: Sun Jul 13, 2014 10:42 pm
by bahar.wadia

That works nicely.

Thank you!


How to scroll screen to the top of an element?

Posted: Fri Jul 18, 2014 11:55 pm
by Beej

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