@@ -20,6 +20,7 @@ import _ from 'lodash'
2020 vm . loadMore = loadMore
2121 vm . getChallenges = getChallenges
2222 vm . totalCount = 0
23+ vm . firstLoadMore = true
2324 // this will help to keep track of pagination across individual api calls
2425 var counts = {
2526 devDesign : { total : 0 , current : 0 } ,
@@ -99,7 +100,7 @@ import _ from 'lodash'
99100
100101 function getDevDesignChallenges ( offset ) {
101102 var params = {
102- limit : 12 ,
103+ limit : CONSTANTS . CHALLENGES_LOADING_CHUNK ,
103104 offset : offset ,
104105 orderBy : vm . orderBy + ' desc' ,
105106 filter : 'status=' + vm . statusFilter
@@ -125,7 +126,7 @@ import _ from 'lodash'
125126 _filter = 'status=past&isRatedForMM=true'
126127 }
127128 var params = {
128- limit : 12 ,
129+ limit : CONSTANTS . CHALLENGES_LOADING_CHUNK ,
129130 offset : offset ,
130131 orderBy : vm . statusFilter === 'active' ? 'startDate' : 'endDate desc' ,
131132 filter : _filter
@@ -142,12 +143,14 @@ import _ from 'lodash'
142143 }
143144
144145 function loadMore ( ) {
145- currentOffset += 12
146- vm . getChallenges ( currentOffset , false )
146+ if ( vm . loading === CONSTANTS . STATE_READY ) {
147+ currentOffset += CONSTANTS . CHALLENGES_LOADING_CHUNK
148+ vm . getChallenges ( currentOffset , false )
149+ }
147150 }
148151
149152 window . onscroll = function ( ) {
150- if ( ( window . innerHeight + window . scrollY ) >= document . body . offsetHeight ) {
153+ if ( ( window . innerHeight + window . scrollY ) >= ( document . body . offsetHeight - CONSTANTS . INFINITE_SCROLL_OFFSET ) ) {
151154 if ( vm . totalCount > vm . myChallenges . length ) {
152155 vm . loadMore ( )
153156 }
0 commit comments