Skip to content

Commit

Permalink
fix(start()): locate parent before every 'start()'
Browse files Browse the repository at this point in the history
When the ng-view is attached to the body
And the route is changed
The the body may be re-written out from under the loading bar
And the $parent object will be invalid

By finding the $parent every time the loading bar is started,
it ensures that the <div> elements aren't attached to a stale
parent.
  • Loading branch information
networkerror authored and chieffancypants committed May 2, 2014
1 parent 8cd8402 commit 124d631
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-loading-bar",
"version": "0.4.0",
"version": "0.4.1",
"main": ["src/loading-bar.js", "src/loading-bar.css"],
"ignore": [
"**/.*",
Expand Down
2 changes: 1 addition & 1 deletion build/loading-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ angular.module('chieffancypants.loadingBar', [])
this.$get = ['$document', '$timeout', '$animate', '$rootScope', function ($document, $timeout, $animate, $rootScope) {

var $parentSelector = this.parentSelector,
$parent = $document.find($parentSelector),
loadingBarContainer = angular.element('<div id="loading-bar"><div class="bar"><div class="peg"></div></div></div>'),
loadingBar = loadingBarContainer.find('div').eq(0),
spinner = angular.element('<div id="loading-bar-spinner"><div class="spinner-icon"></div></div>');
Expand All @@ -186,6 +185,7 @@ angular.module('chieffancypants.loadingBar', [])
* Inserts the loading bar element into the dom, and sets it to 2%
*/
function _start() {
var $parent = $document.find($parentSelector);
$timeout.cancel(completeTimeout);

// do not continually broadcast the started event:
Expand Down
2 changes: 1 addition & 1 deletion build/loading-bar.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-loading-bar",
"version": "0.4.0",
"version": "0.4.1",
"description": "An automatic loading bar for AngularJS",
"main": "src/loading-bar.js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion src/loading-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ angular.module('chieffancypants.loadingBar', [])
this.$get = ['$document', '$timeout', '$animate', '$rootScope', function ($document, $timeout, $animate, $rootScope) {

var $parentSelector = this.parentSelector,
$parent = $document.find($parentSelector),
loadingBarContainer = angular.element('<div id="loading-bar"><div class="bar"><div class="peg"></div></div></div>'),
loadingBar = loadingBarContainer.find('div').eq(0),
spinner = angular.element('<div id="loading-bar-spinner"><div class="spinner-icon"></div></div>');
Expand All @@ -180,6 +179,7 @@ angular.module('chieffancypants.loadingBar', [])
* Inserts the loading bar element into the dom, and sets it to 2%
*/
function _start() {
var $parent = $document.find($parentSelector);
$timeout.cancel(completeTimeout);

// do not continually broadcast the started event:
Expand Down

0 comments on commit 124d631

Please sign in to comment.