Skip to content
This repository was archived by the owner on Dec 30, 2018. It is now read-only.
This repository was archived by the owner on Dec 30, 2018. It is now read-only.

Masonry layout break if you use infinite-scroll and ng-filter with ordering #103

@gopandago

Description

@gopandago

Hi Guys,

Not sure if you have faced this issue or not, when you use angular infinite-scroll and your ng-repeat contains ordering, the Masonry layout breaks

The angular script

studentApp.controller('studentCtrl', function($scope) {

    $scope.students = [
        {studentId: 1, username: "user1",
            dob: "10/01/1970",
            address: { suburb: "Melbourne", state: "vic", postcode: "3000"}},
        {studentId: 2, username: "user2", 
            dob: "10/01/1980",
            address: { suburb: "Melbourne", state: "vic", postcode: "3000"}},
        {studentId: 3, username: "user3",
            dob: "11/01/1980",
            address: { suburb: "Melbourne", state: "vic", postcode: "3000"}},
        {studentId: 4, username: "user4",
            dob: "12/02/1980",
            address: { suburb: "Melbourne", state: "vic", postcode: "3000"}}];

    $scope.loadMore = function() {
        var last = $scope.students[$scope.students.length - 1].studentId;

        for(var i = 1; i < 2; i++) {
            $scope.students.push({
                studentId: last + i, username: "user5",
                dob: "12/02/1980",
                address: { suburb: "Melbourne", state: "vic", postcode: "3000"}});
        }
    };
});

css

.masonry-brick {
    margin: 5px;
    float:left;
    padding:10px;
}

.masonry-brick.loaded {
    display: block;
    border:1px solid;
    border-radius:5px;
    white-space: nowrap;
}

This is my sample html

<div ng-controller="studentCtrl">
Order By:
        <a href="" ng-click="order = 'dob'">DOB</a>

        <div masonry>
            <div infinite-scroll="loadMore()" infinite-scroll-distance='2' infinite-scroll-disabled='false' infinite-scroll-immediate-check='false'>
                <div class="masonry masonry-brick" ng-repeat="student in students | orderBy: order">
                    studentId {{student.studentId}} - {{student.username}}
                    <br>DOB: {{student.dob}}
                    <br>Location: {{student.location.suburb}}, {{student.location.state}}
                </div>
            </div>
        </div>
</div>

If you change the ng-repeat without the ordering like this then it'll work

<div class="masonry masonry-brick" ng-repeat="student in students">
        studentId {{student.studentId}} - {{student.username}}
    <br>DOB: {{student.dob}}
        <br>Location: {{student.location.suburb}}, {{student.location.state}}
</div> 

I have tried to isolate the issue but it seems the reload fails after the infinite scroll is activated? Has anyone experienced this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions