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