2 * Angular Material Design
3 * https://github.com/angular/material
7 (function( window, angular, undefined ){
12 * @name material.components.content
17 mdContentDirective['$inject'] = ["$mdTheming"];
18 angular.module('material.components.content', [
21 .directive('mdContent', mdContentDirective);
26 * @module material.components.content
32 * The `<md-content>` directive is a container element useful for scrollable content. It achieves
33 * this by setting the CSS `overflow` property to `auto` so that content can properly scroll.
35 * In general, `<md-content>` components are not designed to be nested inside one another. If
36 * possible, it is better to make them siblings. This often results in a better user experience as
37 * having nested scrollbars may confuse the user.
41 * In some cases, you may wish to apply the `md-no-momentum` class to ensure that Safari's
42 * momentum scrolling is disabled. Momentum scrolling can cause flickering issues while scrolling
43 * SVG icons and some other components.
45 * Additionally, we now also offer the `md-no-flicker` class which can be applied to any element
46 * and uses a Webkit-specific filter of `blur(0px)` that forces GPU rendering of all elements
47 * inside (which eliminates the flicker on iOS devices).
49 * _<b>Note:</b> Forcing an element to render on the GPU can have unintended side-effects, especially
50 * related to the z-index of elements. Please use with caution and only on the elements needed._
54 * Add the `[layout-padding]` attribute to make the content padded.
57 * <md-content layout-padding>
58 * Lorem ipsum dolor sit amet, ne quod novum mei.
63 function mdContentDirective($mdTheming) {
66 controller: ['$scope', '$element', ContentController],
67 link: function(scope, element) {
68 element.addClass('_md'); // private md component indicator for styling
71 scope.$broadcast('$mdContentLoaded', element);
73 iosScrollFix(element[0]);
77 function ContentController($scope, $element) {
79 this.$element = $element;
83 function iosScrollFix(node) {
85 // If we scroll where there is no more room for the webview to scroll,
86 // by default the webview itself will scroll up and down, this looks really
87 // bad. So if we are scrolling to the very top or bottom, add/subtract one
88 angular.element(node).on('$md.pressdown', function(ev) {
90 if (ev.pointer.type !== 't') return;
91 // Don't let a child content's touchstart ruin it for us.
92 if (ev.$materialScrollFixed) return;
93 ev.$materialScrollFixed = true;
95 if (node.scrollTop === 0) {
97 } else if (node.scrollHeight === node.scrollTop + node.offsetHeight) {
103 })(window, window.angular);