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

Load more past results by scrolling down

parent 1aa410a0
......@@ -396,6 +396,18 @@ streamviewer = [ ->
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'])
.directive('authentication', authentication)
.directive('fuzzytime', fuzzytime)
......@@ -413,3 +425,4 @@ angular.module('h.directives', ['ngSanitize'])
.directive('repeatAnim', repeatAnim)
.directive('notification', notification)
.directive('streamviewer', streamviewer)
.directive('whenscrolled', whenscrolled)
......@@ -242,7 +242,6 @@ class StreamSearch
if data.length
$scope.$apply =>
$scope.empty = false
data = data.sort($scope.sortAnnotations)
$scope.manage_new_data data, action
else
unless $scope.annotations.length
......@@ -277,6 +276,18 @@ class StreamSearch
$scope.annotations.splice index,1
break
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 = []
$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