scroll when clicking on category working

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