Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
feat(input): adds no-float class to disable floating label animations
Browse files Browse the repository at this point in the history
Closes #201
Closes #1392
  • Loading branch information
Robert Messerle authored and ThomasBurleson committed Feb 10, 2015
1 parent 0bd8cf1 commit 33f677e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/components/input/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ angular.module('material.components.input', [
* @description
* `<md-input-container>` is the parent of any input or textarea element.
*
* Input and textarea elements will not behave properly unless the md-input-container
* Input and textarea elements will not behave properly unless the md-input-container
* parent is provided.
*
* @param md-is-error {expression=} When the given expression evaluates to true, the input container will go into error state. Defaults to erroring if the input has been touched and is invalid.
Expand Down Expand Up @@ -85,7 +85,7 @@ function labelDirective() {
restrict: 'E',
require: '^?mdInputContainer',
link: function(scope, element, attr, containerCtrl) {
if (!containerCtrl) return;
if (!containerCtrl || attr.mdNoFloat) return;

containerCtrl.label = element;
scope.$on('$destroy', function() {
Expand Down Expand Up @@ -170,7 +170,7 @@ function inputTextareaDirective($mdUtil, $window, $compile, $animate) {
require: ['^?mdInputContainer', '?ngModel'],
link: postLink
};

function postLink(scope, element, attr, ctrls) {

var containerCtrl = ctrls[0];
Expand All @@ -196,7 +196,7 @@ function inputTextareaDirective($mdUtil, $window, $compile, $animate) {
return ngModelCtrl.$invalid && ngModelCtrl.$touched;
};
scope.$watch(isErrorGetter, containerCtrl.setInvalid);

ngModelCtrl.$parsers.push(ngModelPipelineCheckValue);
ngModelCtrl.$formatters.push(ngModelPipelineCheckValue);

Expand Down Expand Up @@ -290,22 +290,22 @@ function mdMaxlengthDirective($animate) {
var containerCtrl = ctrls[1];
var charCountEl = angular.element('<div class="md-char-counter">');

// Stop model from trimming. This makes it so whitespace
// Stop model from trimming. This makes it so whitespace
// over the maxlength still counts as invalid.
attr.$set('ngTrim', 'false');
containerCtrl.element.append(charCountEl);

ngModelCtrl.$formatters.push(renderCharCount);
ngModelCtrl.$viewChangeListeners.push(renderCharCount);
element.on('input keydown', function() {
element.on('input keydown', function() {
renderCharCount(); //make sure it's called with no args
});

scope.$watch(attr.mdMaxlength, function(value) {
maxlength = value;
if (angular.isNumber(value) && value > 0) {
if (!charCountEl.parent().length) {
$animate.enter(charCountEl, containerCtrl.element,
$animate.enter(charCountEl, containerCtrl.element,
angular.element(containerCtrl.element[0].lastElementChild));
}
renderCharCount();
Expand Down
8 changes: 4 additions & 4 deletions src/components/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ md-input-container {
overflow: hidden;
}

label,
label:not(.md-no-float),
.md-placeholder {
order: 1;
pointer-events: none;
Expand Down Expand Up @@ -74,8 +74,8 @@ md-input-container {
opacity: 0;
}

/*
* The .md-input class is added to the input/textarea
/*
* The .md-input class is added to the input/textarea
*/
.md-input {
flex: 1;
Expand Down Expand Up @@ -139,7 +139,7 @@ md-input-container {

&.md-input-focused,
&.md-input-has-value {
label {
label:not(.md-no-float) {
transform: translate3d(0,$input-label-float-offset,0) scale($input-label-float-scale);
}
}
Expand Down

0 comments on commit 33f677e

Please sign in to comment.