0

How can be made auto scroll of content up when we expand last item on the page? This item is expanding but is not visible until we scroll.. I tried manipulating with css but it doesnt work. Overflow: scroll is enabled. Thank You

Aviator
  • 613
  • 4
  • 11
  • 26
  • You could use Window.scrollTo(x,y) to explicitly change the scroll position. http://www.w3schools.com/jsref/met_win_scrollto.asp – Mic Feb 19 '15 at 15:10
  • yeah but it is easy when you have few of them but here is necessarity to get items from a table, a lot of them, so I don't know exactly positions where to take it :/ – Aviator Feb 19 '15 at 15:23

2 Answers2

1

You can use following approach

On item expanding event execute this:

location.hash = '#item_id';

Here "#" is mandatory

Yogesh Patel
  • 672
  • 4
  • 9
  • do you have maybe some example of this? I would appreciate this – Aviator Feb 19 '15 at 15:37
  • Here's the good example with Smooth Auto Scroll http://www.developphp.com/video/JavaScript/Smooth-Auto-Scroll-Tutorial – Yogesh Patel Feb 19 '15 at 15:57
  • It's a good solution, not one I've ever used. @Dinone Check out this question - he's setting location.hash and trying to make it not scroll, but it should still help if you want to use that way: http://stackoverflow.com/questions/1489624/modifying-document-location-hash-without-page-scrolling – Mic Feb 19 '15 at 16:08
0

try using JQuery Scroll.

var scroll = $(window).scrollTop();

Example: http://jsfiddle.net/satowan/8vqfxet7/

Sato
  • 1