scroll when clicking on category working

parent 133bf447
...@@ -20,7 +20,7 @@ var dashboardControllers = angular.module('dashboardControllers', ['dashboardCon ...@@ -20,7 +20,7 @@ var dashboardControllers = angular.module('dashboardControllers', ['dashboardCon
// Main Controller // Main Controller
// //
// //
dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $location, $translate) { dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $location, $translate, $rootScope) {
// Always use objects if we want to modify this scope in the childs // Always use objects if we want to modify this scope in the childs
...@@ -56,6 +56,14 @@ dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $ ...@@ -56,6 +56,14 @@ dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $
$scope.logout(); $scope.logout();
}); });
//-------------------------------------------
// For scrolling when using routig
//
$rootScope.$on('$routeChangeSuccess', function(newRoute, oldRoute) {
$location.hash($routeParams.scrollTo);
$anchorScroll();
});
//--------------------------------------------------------------- //---------------------------------------------------------------
// Controller's functions // Controller's functions
// //
......
...@@ -13,7 +13,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -13,7 +13,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$http, $http,
config, config,
$window, $window,
$location,
$filter, $filter,
$anchorScroll,
$modal) { $modal) {
$scope.emptyStudentPicto = { $scope.emptyStudentPicto = {
id: null, id: null,
...@@ -119,11 +121,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -119,11 +121,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope.show_category = function (studentPicto) { $scope.show_category = function (studentPicto) {
if ($scope.isCategory(studentPicto)) { if ($scope.isCategory(studentPicto)) {
$scope.selectedCategory = studentPicto; $scope.selectedCategory = studentPicto;
setTimeout(function () { $location.hash('picto-category-grid');
$(document.body).animate({ $anchorScroll();
scrollTop: $('#picto-category-grid').position().top
}, 500);
}, 0);
} }
}; };
......
...@@ -125,6 +125,7 @@ ...@@ -125,6 +125,7 @@
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
</div> </div>
<a name="picto-category-grid"/>
<div <div
id="picto-category-grid" id="picto-category-grid"
class="picto-grid picto-category-grid" class="picto-grid picto-category-grid"
......
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 sign in to comment