forked from Archives/Athou_commafeed
wip: mark items as the user scrolls past them (#62)
This commit is contained in:
@@ -127,6 +127,8 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat
|
||||
$timeout(function refreshTree() {
|
||||
CategoryService.init(function() {
|
||||
$timeout(refreshTree, 15000);
|
||||
}, function() {
|
||||
$timeout(refreshTree, 15000);
|
||||
});
|
||||
}, 15000);
|
||||
|
||||
@@ -536,10 +538,10 @@ function($scope, $stateParams, $http, $route, $window, EntryService, SettingsSer
|
||||
}
|
||||
};
|
||||
|
||||
$scope.isOpen = false;
|
||||
$scope.isOpen = SettingsService.settings.viewMode == 'expanded';
|
||||
$scope.entryClicked = function(entry, event) {
|
||||
if (!event.ctrlKey && event.which != 2) {
|
||||
if ($scope.current != entry) {
|
||||
if ($scope.current != entry || SettingsService.settings.viewMode == 'expanded') {
|
||||
$scope.isOpen = true;
|
||||
} else {
|
||||
$scope.isOpen = !$scope.isOpen;
|
||||
@@ -604,6 +606,14 @@ function($scope, $stateParams, $http, $route, $window, EntryService, SettingsSer
|
||||
}
|
||||
};
|
||||
|
||||
$scope.onScroll = function(entry) {
|
||||
if (SettingsService.settings.viewMode == 'expanded'){
|
||||
$scope.current = entry;
|
||||
if(SettingsService.settings.scrollMarks) {
|
||||
$scope.mark(entry, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Mousetrap.bind('j', function(e) {
|
||||
$scope.$apply(function() {
|
||||
|
||||
@@ -60,6 +60,53 @@ module.directive('ngBlur', function() {
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Fired when the top of the element is not visible anymore
|
||||
*/
|
||||
module.directive('onScrollMiddle', function () {
|
||||
return {
|
||||
restrict : 'A',
|
||||
link : function(scope, element, attrs) {
|
||||
|
||||
var w = $(window);
|
||||
var e = $(element);
|
||||
|
||||
var direction = 'down';
|
||||
|
||||
var down = function() {
|
||||
var docTop = w.scrollTop();
|
||||
var docMiddle = docTop + w.height() / 2;
|
||||
var elemTop = e.offset().top;
|
||||
return (elemTop > docMiddle) ? 'below' : 'above';
|
||||
};
|
||||
var up = function() {
|
||||
var docTop = w.scrollTop();
|
||||
var docMiddle = docTop + w.height() / 2;
|
||||
var elemTop = e.offset().top;
|
||||
var elemBottom = elemTop + e.height();
|
||||
|
||||
return (elemBottom > docMiddle) ? 'below' : 'above';
|
||||
};
|
||||
|
||||
if(!w.data.scrollInit){
|
||||
$(window).bind('scroll', function(e) {
|
||||
var direction = e.detail > 0 ? 'down' : 'up';
|
||||
scope.$apply();
|
||||
});
|
||||
w.data.scrollInit = true;
|
||||
}
|
||||
scope.$watch(down, function(value, oldValue) {
|
||||
if(direction == 'down' && value && oldValue && value != oldValue)
|
||||
scope.$eval(attrs.onScrollMiddle);
|
||||
});
|
||||
scope.$watch(up, function(value, oldValue) {
|
||||
if(direction == 'up' && value && oldValue && value != oldValue)
|
||||
scope.$eval(attrs.onScrollMiddle);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Scrolls to the element if the value is true
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user