-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from diggyk/master
Added the missing box-continuation directive
- Loading branch information
Showing
3 changed files
with
101 additions
and
14 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,37 @@ | ||
/** | ||
* Directive for watching a div and adding a "box-continuation" class when a | ||
* particular height is reached. This is used when we have a max-height for a div | ||
* with a scroll and want to clue the user in to the fact that the box has additional | ||
* items in it. | ||
* | ||
* A "watch" attribute must be specified that let's us know what data | ||
* modifies the contents of the div (and therefore might alter the height). | ||
*/ | ||
(function() { | ||
function boxContinuation () { | ||
return { | ||
restrict: 'A', | ||
scope: { | ||
'watch': '=' | ||
}, | ||
link: function ($scope, $ele, $attrs) { | ||
var triggerHeight = $attrs.triggerHeight || 200; | ||
|
||
$scope.$watch('watch', | ||
classAlteration, true); | ||
|
||
function classAlteration() { | ||
setTimeout(function() { | ||
if ($ele[0].clientHeight >= triggerHeight) { | ||
$ele[0].classList.add('box-continuation'); | ||
} else { | ||
$ele[0].classList.remove('box-continuation'); | ||
} | ||
}, 1); | ||
} | ||
} | ||
} | ||
} | ||
|
||
angular.module('hermesApp').directive('boxContinuation', boxContinuation); | ||
})(); |
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