mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
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:
committed by
Blade Barringer
parent
a3f83b9076
commit
7d7bb3ecb8
@@ -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',
|
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) {
|
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 user = User.user;
|
||||||
|
var IGNORE_SCROLL_PAGES = {
|
||||||
|
'options.social.challenges.detail': true,
|
||||||
|
'options.social.challenges': true
|
||||||
|
};
|
||||||
|
|
||||||
// Setup page once user is synced
|
// Setup page once user is synced
|
||||||
var clearAppLoadedListener = $rootScope.$watch('appLoaded', function (after) {
|
var clearAppLoadedListener = $rootScope.$watch('appLoaded', function (after) {
|
||||||
@@ -25,7 +29,9 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
function(event, toState, toParams, fromState, fromParams){
|
function(event, toState, toParams, fromState, fromParams){
|
||||||
$rootScope.pageTitle = $state.current.title;
|
$rootScope.pageTitle = $state.current.title;
|
||||||
|
|
||||||
|
if (!($state.current.name in IGNORE_SCROLL_PAGES)) {
|
||||||
$window.scrollTo(0, 0);
|
$window.scrollTo(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (!!fromState.name) Analytics.track({'hitType':'pageview','eventCategory':'navigation','eventAction':'navigate','page':'/#/'+toState.name});
|
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) {
|
if (toState.name=='options.social.inbox' && User.user.inbox && User.user.inbox.newMessages > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user