diff --git a/ionic/components/content/content.ts b/ionic/components/content/content.ts index ac0c2ecf88..83e6765864 100644 --- a/ionic/components/content/content.ts +++ b/ionic/components/content/content.ts @@ -4,7 +4,7 @@ import {Ion} from '../ion'; import {IonicConfig} from '../../config/config'; import {IonicKeyboard} from '../../util/keyboard'; import {ViewController} from '../nav/view-controller'; -import {Tab} from '../tabs/tab'; +import {Animation} from '../../animations/animation'; import {ScrollTo} from '../../animations/scroll-to'; @@ -25,8 +25,10 @@ import {ScrollTo} from '../../animations/scroll-to'; */ @Component({ selector: 'ion-content', - inputs: ['parallax'], - template: '' + template: + '' + + '' + + '' }) export class Content extends Ion { /** @@ -38,7 +40,7 @@ export class Content extends Ion { this.scrollPadding = 0; this.keyboard = keyboard; - if(viewCtrl) { + if (viewCtrl) { viewCtrl.setContent(this); } } @@ -58,7 +60,7 @@ export class Content extends Ion { * @returns {Function} A function that removes the scroll handler. */ addScrollEventListener(handler) { - if(!this.scrollElement) { return; } + if (!this.scrollElement) { return; } // ensure we're not creating duplicates this.scrollElement.removeEventListener('scroll', handler); @@ -76,7 +78,7 @@ export class Content extends Ion { * @returns {Function} A function that removes the touchmove handler. */ addTouchMoveListener(handler) { - if(!this.scrollElement) { return; } + if (!this.scrollElement) { return; } // ensure we're not creating duplicates this.scrollElement.removeEventListener('touchmove', handler); @@ -161,17 +163,29 @@ export class Content extends Ion { * Adds padding to the bottom of the scroll element when the keyboard is open * so content below the keyboard can be scrolled into view. */ - addKeyboardPadding(addPadding) { - if (addPadding > this.scrollPadding) { - this.scrollPadding = addPadding; - this.scrollElement.style.paddingBottom = addPadding + 'px'; + addScrollPadding(newScrollPadding) { + if (newScrollPadding > this.scrollPadding) { + console.debug('addScrollPadding', newScrollPadding); + + this.scrollPadding = newScrollPadding; + this.scrollElement.style.paddingBottom = newScrollPadding + 'px'; if (!this.keyboardPromise) { + console.debug('add scroll keyboard close callback', newScrollPadding); this.keyboardPromise = this.keyboard.onClose(() => { + console.debug('scroll keyboard closed', newScrollPadding); + if (this) { + if (this.scrollPadding && this.scrollElement) { + let close = new Animation(this.scrollElement); + close + .duration(150) + .fromTo('paddingBottom', this.scrollPadding + 'px', '0px') + .play(); + } + this.scrollPadding = 0; - if (this.scrollElement) this.scrollElement.style.paddingBottom = ''; this.keyboardPromise = null; } }); diff --git a/ionic/components/text-input/label.ts b/ionic/components/text-input/label.ts index 0134388e83..4b293f3a79 100644 --- a/ionic/components/text-input/label.ts +++ b/ionic/components/text-input/label.ts @@ -25,9 +25,13 @@ export class Label { * TODO * @param {IonicConfig} config */ - constructor(config: IonicConfig, @Optional() textInput: TextInput) { - this.scrollAssist = config.get('keyboardScrollAssist'); - textInput && textInput.registerLabel(this); + constructor(config: IonicConfig, @Optional() container: TextInput) { + this.scrollAssist = config.get('scrollAssist'); + if (!this.id) { + this.id = 'lbl-' + (++labelIds); + } + this.container = container; + container && container.registerLabel(this); } /** @@ -55,7 +59,7 @@ export class Label { if (!hasPointerMoved(20, this.startCoord, endCoord)) { ev.preventDefault(); ev.stopPropagation(); - this.container.focus(); + this.container.initFocus(); } this.startCoord = null; @@ -63,3 +67,5 @@ export class Label { } } + +let labelIds = -1; diff --git a/ionic/components/text-input/test/input-focus/index.ts b/ionic/components/text-input/test/input-focus/index.ts new file mode 100644 index 0000000000..43aed36502 --- /dev/null +++ b/ionic/components/text-input/test/input-focus/index.ts @@ -0,0 +1,7 @@ +import {App} from 'ionic/ionic'; + + +@App({ + templateUrl: 'main.html' +}) +class E2EApp {} diff --git a/ionic/components/text-input/test/input-focus/main.html b/ionic/components/text-input/test/input-focus/main.html new file mode 100644 index 0000000000..8ab18e4e1b --- /dev/null +++ b/ionic/components/text-input/test/input-focus/main.html @@ -0,0 +1,188 @@ + +Input Focus + + + + +

Paragraph text with a link.

+ + + + + Text 1: + + + + + Item with button right + + + + + Text 2: + + + + + + + Text 3: + + + + + + Comments: + + + + + + Website: + + + + + + Email: + + + + + + Feedback: + + + + + More Info: + + + + + + Score: + + + + + + First Name: + + + + + Last Name: + + + + + Message: + + + + + Item + + + + Item + + + + + + + +
diff --git a/ionic/components/text-input/text-input.scss b/ionic/components/text-input/text-input.scss index e341572096..cb1eac4d56 100644 --- a/ionic/components/text-input/text-input.scss +++ b/ionic/components/text-input/text-input.scss @@ -2,9 +2,6 @@ // Text Input // -------------------------------------------------- -$input-focus-border-color: #51a7e8 !default; -$input-focus-box-shadow: inset 0px 0px 8px 0px $input-focus-border-color !default; - $text-input-background-color: $list-background-color !default; @@ -37,18 +34,6 @@ ion-input.item { align-items: flex-start; } -.key-input ion-input { - - &.has-focus { - border-color: $input-focus-border-color; - box-shadow: $input-focus-box-shadow; - } - - :focus { - outline: none; - } -} - ion-input [text-input] { flex: 1; background-color: $text-input-background-color; @@ -59,6 +44,13 @@ ion-input.has-focus [text-input] { pointer-events: auto; } +ion-input input[scroll-assist] { + display: inline-block; + width: 1px; + height: 1px; + pointer-events: none; +} + ion-input textarea { padding-top: 9px; } @@ -80,4 +72,3 @@ input, textarea { @include placeholder(); } - diff --git a/ionic/components/text-input/text-input.ts b/ionic/components/text-input/text-input.ts index baac463615..63cc6cf6c3 100644 --- a/ionic/components/text-input/text-input.ts +++ b/ionic/components/text-input/text-input.ts @@ -1,4 +1,4 @@ -import {Directive, Host, Optional, ElementRef, Renderer, Attribute, Query, QueryList, NgZone} from 'angular2/angular2'; +import {Component, Directive, NgIf, forwardRef, Host, Optional, ElementRef, Renderer, Attribute, Query, QueryList, NgZone} from 'angular2/angular2'; import {IonicConfig} from '../../config/config'; import {IonicForm} from '../../util/form'; @@ -12,29 +12,20 @@ import {IonicPlatform} from '../../platform/platform'; /** * TODO */ -@Directive({ +@Component({ selector: 'ion-input', host: { - '(focus)': 'receivedFocus(true)', - '(blur)': 'receivedFocus(false)', '(touchstart)': 'pointerStart($event)', '(touchend)': 'pointerEnd($event)', - '(mouseup)': 'pointerEnd($event)', - '[class.has-focus]': 'hasFocus', - '[class.has-value]': 'hasValue' - } + '(mouseup)': 'pointerEnd($event)' + }, + template: + '' + + '', + directives: [NgIf, forwardRef(() => InputScrollAssist)] }) export class TextInput { - /** - * TODO - * @param {ElementRef} elementRef TODO - * @param {IonicConfig} config TODO - * @param {IonicApp} app TODO - * @param {NgZone} ngZone TODO - * @param {Content=} scrollView The parent scroll view. - * @param {QueryList} inputQry TODO - * @param {QueryList