Skip to content

Commit be5413c

Browse files
committed
Merge pull request #10 from protherj/patch-1
Fix for the "oldClass" not showing in the event, first time the event wasn't fired
2 parents 9d4cbf3 + 015c415 commit be5413c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

breakpoint-0.0.1.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*!
32
* angularjs-breakpoint v0.0.1
43
*
@@ -21,6 +20,7 @@ breakpointApp.directive('breakpoint', ['$window', '$rootScope', function($window
2120
scope.breakpoint = {class:'', windowSize:$window.innerWidth }; // Initialise Values
2221

2322
var breakpoints = (scope.$eval(attr.breakpoint));
23+
var firstTime = true;
2424

2525
angular.element($window).bind('resize', setWindowSize);
2626

@@ -29,7 +29,10 @@ breakpointApp.directive('breakpoint', ['$window', '$rootScope', function($window
2929
});
3030

3131
scope.$watch('breakpoint.class', function(newClass, oldClass) {
32-
if (newClass != oldClass) broadcastEvent();
32+
if (newClass != oldClass || firstTime) {
33+
broadcastEvent(oldClass);
34+
firstTime = false;
35+
}
3336
});
3437

3538
function broadcastEvent (oldClass) {

0 commit comments

Comments
 (0)