Commit 99bbdc01 authored by Ujvari Gergely's avatar Ujvari Gergely

Load more past results by scrolling down

parent 1aa410a0
...@@ -396,6 +396,18 @@ streamviewer = [ -> ...@@ -396,6 +396,18 @@ streamviewer = [ ->
templateUrl: 'streamviewer.html' templateUrl: 'streamviewer.html'
] ]
whenscrolled = ['$window', ($window) ->
link: (scope, elem, attr) ->
$window = angular.element($window)
$window.on 'scroll', ->
windowBottom = $window.height() + $window.scrollTop()
elementBottom = elem.offset().top + elem.height()
remaining = elementBottom - windowBottom
shouldScroll = remaining <= $window.height() * 0
if shouldScroll
scope.$apply attr.whenscrolled
]
angular.module('h.directives', ['ngSanitize']) angular.module('h.directives', ['ngSanitize'])
.directive('authentication', authentication) .directive('authentication', authentication)
.directive('fuzzytime', fuzzytime) .directive('fuzzytime', fuzzytime)
...@@ -413,3 +425,4 @@ angular.module('h.directives', ['ngSanitize']) ...@@ -413,3 +425,4 @@ angular.module('h.directives', ['ngSanitize'])
.directive('repeatAnim', repeatAnim) .directive('repeatAnim', repeatAnim)
.directive('notification', notification) .directive('notification', notification)
.directive('streamviewer', streamviewer) .directive('streamviewer', streamviewer)
.directive('whenscrolled', whenscrolled)
...@@ -242,7 +242,6 @@ class StreamSearch ...@@ -242,7 +242,6 @@ class StreamSearch
if data.length if data.length
$scope.$apply => $scope.$apply =>
$scope.empty = false $scope.empty = false
data = data.sort($scope.sortAnnotations)
$scope.manage_new_data data, action $scope.manage_new_data data, action
else else
unless $scope.annotations.length unless $scope.annotations.length
...@@ -277,6 +276,18 @@ class StreamSearch ...@@ -277,6 +276,18 @@ class StreamSearch
$scope.annotations.splice index,1 $scope.annotations.splice index,1
break break
index +=1 index +=1
$scope.annotations = $scope.annotations.sort($scope.sortAnnotations)
$scope.loadMore = (number) =>
console.log 'loadMore'
unless $scope.sock? then return
sockmsg =
messageType: 'more_hits'
clientID: @clientID
moreHits: number
$scope.sock.send JSON.stringify sockmsg
$scope.annotations = [] $scope.annotations = []
$timeout => $timeout =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment