scroll when clicking on category working

parent 133bf447
......@@ -20,12 +20,12 @@ 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
// Save name and surname in global scope
$scope.user = {
$scope.user = {
id: '',
name: '',
surname: '',
......@@ -43,7 +43,7 @@ dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $
lang = 'es-es';
$translate.use(lang);
//$translateProvider.preferredLanguage('es-es');
//---------------------------------------------------------------
......@@ -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
//
......@@ -77,4 +85,4 @@ dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $
// Redirect to login
$location.path('/login');
};
});
\ No newline at end of file
});
......@@ -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