Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
(#10) Added comment and refactored scrollWidgetIntoview function
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Schulte committed Aug 18, 2015
1 parent 619575e commit 3dd520c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ax-messages-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define( [
'use strict';

var DID_ENCOUNTER_ERROR_RESOURCE = '_DID_ENCOUNTER_ERROR_RESOURCE';
var EVENT_SCROLL_TO_MESSAGES = 'SCROLL_TO_MESSAGES';
var EVENT_SCROLL_TO_MESSAGES = 'axMessagesWidget.scrollToMessages';

var levelMap = {
BLANK: { weight: 0 },
Expand Down Expand Up @@ -297,11 +297,14 @@ define( [
////////////////////////////////////////////////////////////////////////////////////////////////////////

function scrollWidgetIntoView() {
if( $scope.features.autoScroll.enabled ) {
setTimeout( function() {
$scope.$broadcast( EVENT_SCROLL_TO_MESSAGES );
}, 0 );
if( !$scope.features.autoScroll.enabled ) {
return;
}
// in case the are no messages yet, we set a timeout to ensure that the directive
// axMessagesAutoScroll has registered to the event and is not still blocked by the ngIf
setTimeout( function() {
$scope.$broadcast( EVENT_SCROLL_TO_MESSAGES );
}, 0 );
}
}

Expand Down

0 comments on commit 3dd520c

Please sign in to comment.