Sha256: 1f0f5e5a159af4c36cf38a1dbd921e0169b630cca9df083968e34b44da4f70ce
Contents?: true
Size: 1.71 KB
Versions: 18
Compression:
Stored size: 1.71 KB
Contents
/** * @ngdoc directive * @name Bastion.components.directive:bstContainerScroll * @restrict A * * @requires $window * @requires $timeout * * @description * The container scroll directive should be applied to a wrapping div around an element that * you wish to have scrolling capabilities that is outside the standard browser flow. * * @example * <pre> <div bst-container-scroll></div> </pre> */ angular.module('Bastion.components').directive('bstContainerScroll', ['$window', '$timeout', function ($window, $timeout) { return { restrict: 'A', compile: function (tElement) { tElement.addClass("container-scroll-wrapper"); return function (scope, element) { var windowElement = angular.element($window), bottomPadding = parseInt(element.css('padding-bottom').replace('px', ''), 10), newElementHeight, addScroll; addScroll = function () { var windowHeight = windowElement.height(), offset = element.offset().top; if (bottomPadding) { offset = offset + bottomPadding; } newElementHeight = windowHeight - offset; if (newElementHeight <= 100) { newElementHeight = 300; } element.outerHeight(newElementHeight); element.height(newElementHeight); }; windowElement.bind('resize', addScroll); $timeout(function () { windowElement.trigger('resize'); }, 0); }; } }; }]);
Version data entries
18 entries across 18 versions & 1 rubygems