-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* height of sidebar is set dynamic through dynamicElementHeightComponent Directive * styled out layout dynamicly through ng-class="{'sidebar-active': sidebarEnabled == 'true'}"
- Loading branch information
Showing
5 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
angular.module('uxDirectives', ['config']) | ||
|
||
.directive('dynamicElementHeightComponent', [ '$rootScope', function( $rootScope ) { | ||
return { | ||
restrict: 'EA', | ||
scope: {}, | ||
link: function(scope, element, attributes) { | ||
angular.element(document).ready( function () { | ||
|
||
function changeSidebarHeigthDynamicly() { | ||
element.height(Math.max($("body").height(), $("aside").height())); | ||
} | ||
|
||
function ifBigScreenAdaptedSidebarHeightElseSetToAuto () { | ||
if ( window.innerWidth > 800 ) { | ||
changeSidebarHeigthDynamicly(); | ||
} | ||
else { | ||
element.css('height','auto'); | ||
} | ||
} | ||
|
||
// on init | ||
setTimeout( function () { | ||
ifBigScreenAdaptedSidebarHeightElseSetToAuto(); | ||
}, 200 ); | ||
|
||
// if window become resized reset height of sidebar | ||
var lastWidth = $(window).width(); | ||
|
||
$(window).resize(function() { | ||
if ( window.innerWidth != lastWidth) { | ||
lastWidth = window.innerWidth; | ||
setTimeout( function () { | ||
ifBigScreenAdaptedSidebarHeightElseSetToAuto(); | ||
}, 200 ); | ||
} | ||
}) | ||
|
||
|
||
$rootScope.$on('$locationChangeStart', function (event, next, current) { | ||
setTimeout( function () { | ||
ifBigScreenAdaptedSidebarHeightElseSetToAuto(); | ||
}, 300 ); | ||
}); | ||
|
||
}) | ||
} | ||
} | ||
}]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<main class="container"> | ||
<main ng-class="{'sidebar-active': sidebarEnabled == 'true'}"> | ||
<div ng-view></div> | ||
</main> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters