# Scroll returns to top

**URL:** <https://forum.ionicframework.com/t/scroll-returns-to-top/617>\
**Category:** ionic-v1\
**Created:** [January 22, 2014, 2:37pm UTC](https://forum.ionicframework.com/t/scroll-returns-to-top/617 "2014-01-22T14:37:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![LS05](https://avatars.discourse-cdn.com/v4/letter/l/e19b73/32.png) [@LS05](https://forum.ionicframework.com/u/LS05)\
**Post date:** [January 22, 2014, 2:37pm UTC](https://forum.ionicframework.com/t/scroll-returns-to-top/617/1 "2014-01-22T14:37:55Z")

</div>

Hi, i’ve got a problem with the `<scroll>` element. After i put a list in that. I start scrolling it, but after releasing the scroll it returns to the top! How can i change that?  
Thanks.

---

<div class="post-metadata">

**Author:** ![Ciraxis](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Ciraxis](https://forum.ionicframework.com/u/Ciraxis)\
**Post date:** [January 22, 2014, 7:50pm UTC](https://forum.ionicframework.com/t/scroll-returns-to-top/617/2 "2014-01-22T19:50:43Z")

</div>

Hi,

on which device/os you have the problem?  
Maybe you can share the code snippet, so we can take a deeper look into the code.

---

<div class="post-metadata">

**Author:** ![johndoe](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@johndoe](https://forum.ionicframework.com/u/johndoe)\
**Post date:** [January 22, 2014, 8:33pm UTC](https://forum.ionicframework.com/t/scroll-returns-to-top/617/3 "2014-01-22T20:33:47Z")

</div>

I encountered similar problems. I have a list within a content container, when i open a modal and then close it again, the scroll position is back at the top of the list.

---

<div class="post-metadata">

**Author:** ![LS05](https://avatars.discourse-cdn.com/v4/letter/l/e19b73/32.png) [@LS05](https://forum.ionicframework.com/u/LS05)\
**Post date:** [January 22, 2014, 11:28pm UTC](https://forum.ionicframework.com/t/scroll-returns-to-top/617/4 "2014-01-22T23:28:46Z")

</div>

I’m trying it in the browser. Anyway here the snippet:

```
       <scroll direction="y">
        <list id="list">
            <item 
                ng-repeat="item in items" 
                ng-href="#/path/to/elem">
                <p class="nome">{{item.nome}}</p>
                <p class="posiz"><i class="ion-location"></i>{{item.posiz}}</p>
            </item>
        </list>
    </scroll>
```

---

<div class="post-metadata">

**Author:** ![LS05](https://avatars.discourse-cdn.com/v4/letter/l/e19b73/32.png) [@LS05](https://forum.ionicframework.com/u/LS05)\
**Post date:** [January 23, 2014, 12:10pm UTC](https://forum.ionicframework.com/t/scroll-returns-to-top/617/5 "2014-01-23T12:10:56Z")

</div>

I’ve found this solution.  
**My Controller**

```
batApp.controller('MyController', function($scope, $routeParams, $document) {
$scope.scollFunction = function(elem){

  var s = document.getElementById(elem);

  var scroll = new ionic.views.Scroll({
    el: s
  });
}; 
});

```

And then in my view:

```
    <div id="scroller" class="scroll">
        <ul class="list">
            <li 
                 ng-repeat="item in items" 
                 ng-href="#/path/to/elem">
                <p class="nome">{{item.nome}}</p>
                <p class="posiz"><i class="ion-location"></i>{{item.posiz}}</p>
            </li>
        </ul>
    </div>
    <div ng-init="scollFunction('scroller')"></div>
```

---

<div class="post-metadata">

**Author:** ![max](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/max/32/137761_2.png) [@max](https://forum.ionicframework.com/u/max)\
**Post date:** [January 23, 2014, 3:24pm UTC](https://forum.ionicframework.com/t/scroll-returns-to-top/617/6 "2014-01-23T15:24:55Z")

</div>

Hey @LS05, I’d advise against that solution as you are using a controller for what a directive should be.

Any chance you have a demo we can see? I’m not seeing any of those scroll issues in my tests, so I wonder if it’s something being done incorrectly elsewhere.

---

<div class="post-metadata">

**Author:** ![bramslob](https://avatars.discourse-cdn.com/v4/letter/b/3da27b/32.png) [@bramslob](https://forum.ionicframework.com/u/bramslob)\
**Post date:** [February 6, 2014, 10:57am UTC](https://forum.ionicframework.com/t/scroll-returns-to-top/617/7 "2014-02-06T10:57:55Z")

</div>

I am having the exact same issue. I believe it has to do with the dynamic change in height.  
What is the correct API call to reinit te scroller to the new height?

Even if I just put the expected full code in, I still end up being thrown back up. It seems to go up to -20px.

Any Ideas 😧

---

<div class="post-metadata">

**Author:** ![bramslob](https://avatars.discourse-cdn.com/v4/letter/b/3da27b/32.png) [@bramslob](https://forum.ionicframework.com/u/bramslob)\
**Post date:** [February 6, 2014, 11:18am UTC](https://forum.ionicframework.com/t/scroll-returns-to-top/617/8 "2014-02-06T11:18:08Z")

</div>

It works for me now.  
I had to replace my ionic.css (which was 0.9.23-alpha) with the version off of [http://code.ionicframework.com/0.9.23/css/ionic.min.css](http://code.ionicframework.com/0.9.23/css/ionic.min.css)

Works now

---

<div class="post-metadata">

**Author:** ![escorpion121](https://avatars.discourse-cdn.com/v4/letter/e/6a8cbe/32.png) [@escorpion121](https://forum.ionicframework.com/u/escorpion121)\
**Post date:** [July 25, 2015, 11:10pm UTC](https://forum.ionicframework.com/t/scroll-returns-to-top/617/9 "2015-07-25T23:10:53Z")

</div>

hi look putt tag \< \> ok

in this code that you need is put ion-content/ion-content like this ok this is your code

scroll direction="y"  
ion-listt id="list"  
item  
ng-repeat=“item in items"  
ng-href=”#/path/to/elem"  
p class=“nome”{{item.nome}}/p  
p class="posiz"i class=“ion-location”/i{{item.posiz}}/p  
/item  
/list  
/scroll

----------- and be like this and remenber too ion-listand ion-item for list and item

ion-content  
ion-list id="list"  
ion-item  
ng-repeat=“item in items"  
ng-href=”#/path/to/elem"  
p class=“nome”{{item.nome}}/p  
p class="posiz"i class=“ion-location”/i{{item.posiz}}/p  
/ion-item  
/ion-list  
/ion-content

and everything fine now if want to use scroll you need to give a height or widht using css(style) for example  
the same code a use a the ion-scroll its insede a ion-content ok

if you only put ion-scroll when you try return to the top then you need

ion-content  
ion-scroll direction=“xy” style="height:500px;width:500px"  
ion-list id="list"  
ion-item  
ng-repeat=“item in items"  
ng-href=”#/path/to/elem"  
p class=“nome”{{item.nome}}/p  
p class=“posiz"i class=“ion-location”/i{{item.posiz}}/p  
/ion-item  
/ion-list  
/ion-scroll  
/ion-content”

and everything fine you want add other carateristica like zooming=“true” you can do it.
