Prevent Challenge page from scrolling to top (#7975)

* Test pageTitle challenge

* Test state name challenge detail

* Change != to !==

* IGNORE_SCROLL_PAGES

* add challenge to ignore_scroll
This commit is contained in:
Oziris Moreira
2016-09-09 10:51:08 -03:00
committed by Blade Barringer
parent a3f83b9076
commit 7d7bb3ecb8

View File

@@ -6,6 +6,10 @@
habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal', '$timeout', 'ApiUrl', 'Payments','$sce','$window','Analytics','TAVERN_ID',
function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout, ApiUrl, Payments, $sce, $window, Analytics, TAVERN_ID) {
var user = User.user;
var IGNORE_SCROLL_PAGES = {
'options.social.challenges.detail': true,
'options.social.challenges': true
};
// Setup page once user is synced
var clearAppLoadedListener = $rootScope.$watch('appLoaded', function (after) {
@@ -25,7 +29,9 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
function(event, toState, toParams, fromState, fromParams){
$rootScope.pageTitle = $state.current.title;
$window.scrollTo(0, 0);
if (!($state.current.name in IGNORE_SCROLL_PAGES)) {
$window.scrollTo(0, 0);
}
if (!!fromState.name) Analytics.track({'hitType':'pageview','eventCategory':'navigation','eventAction':'navigate','page':'/#/'+toState.name});
if (toState.name=='options.social.inbox' && User.user.inbox && User.user.inbox.newMessages > 0) {