mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
input updates
This commit is contained in:
@@ -4,12 +4,6 @@ ion-input {
|
||||
display: block;
|
||||
}
|
||||
|
||||
input.disable-focus,
|
||||
textarea.disable-focus,
|
||||
select.disable-focus {
|
||||
//pointer-events: none;
|
||||
}
|
||||
|
||||
focus-holder input {
|
||||
position: fixed;
|
||||
top: 1px;
|
||||
|
||||
@@ -59,8 +59,7 @@ export class Input extends Ion {
|
||||
'(mousedown)': 'pointerStart($event)',
|
||||
'(mouseup)': 'pointerEnd($event)',
|
||||
'[attr.id]': 'id',
|
||||
'[attr.aria-labelledby]': 'labelledBy',
|
||||
'[class.disable-focus]': 'disableFocus'
|
||||
'[attr.aria-labelledby]': 'labelledBy'
|
||||
}
|
||||
})
|
||||
export class TextInput extends IonInput {
|
||||
@@ -88,26 +87,28 @@ export class TextInput extends IonInput {
|
||||
|
||||
pointerStart(ev) {
|
||||
if (this.scrollAssist) {
|
||||
// remember where the touchstart/mousedown started
|
||||
this.startCoord = dom.pointerCoord(ev);
|
||||
this.disableFocus = true;
|
||||
this.pressStart = Date.now();
|
||||
}
|
||||
}
|
||||
|
||||
pointerEnd(ev) {
|
||||
if (this.scrollAssist) {
|
||||
|
||||
// get where the touchend/mouseup ended
|
||||
let endCoord = dom.pointerCoord(ev);
|
||||
|
||||
// focus this input if the pointer hasn't moved XX pixels
|
||||
// and the input doesn't already have focus
|
||||
if (this.startCoord && !dom.hasPointerMoved(20, this.startCoord, endCoord) && !this.hasFocus()) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
this.focus();
|
||||
|
||||
} else {
|
||||
this.disableFocus = false;
|
||||
}
|
||||
|
||||
this.startCoord = null;
|
||||
this.startCoord = this.pressStart = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,8 +116,6 @@ export class TextInput extends IonInput {
|
||||
let scrollView = this.scrollView;
|
||||
|
||||
if (scrollView && this.scrollAssist) {
|
||||
this.disableFocus = true;
|
||||
|
||||
// this input is inside of a scroll view
|
||||
// scroll the input to the top
|
||||
let inputY = this.elementRef.nativeElement.offsetTop - 8;
|
||||
@@ -139,27 +138,28 @@ export class TextInput extends IonInput {
|
||||
|
||||
// all good, allow clicks again
|
||||
ClickBlock(false);
|
||||
|
||||
this.disableFocus = false;
|
||||
});
|
||||
|
||||
} else {
|
||||
// not inside of a scroll view, just focus it
|
||||
this.setFocus();
|
||||
this.disableFocus = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
receivedFocus(receivedFocus) {
|
||||
console.log('receivedFocus: ', receivedFocus)
|
||||
let self = this;
|
||||
let scrollView = self.scrollView;
|
||||
|
||||
self.isActiveInput(receivedFocus);
|
||||
|
||||
function touchMove(ev) {
|
||||
self.setFocusHolder(self.type);
|
||||
self.deregTouchMove();
|
||||
console.log('touchMove')
|
||||
if (!self.isPressHold()) {
|
||||
self.setFocusHolder(self.type);
|
||||
self.deregTouchMove();
|
||||
}
|
||||
}
|
||||
|
||||
if (scrollView && this.scrollAssist) {
|
||||
@@ -176,6 +176,11 @@ export class TextInput extends IonInput {
|
||||
|
||||
}
|
||||
|
||||
isPressHold() {
|
||||
console.log('pressStart:', this.pressStart, ' pressStart + 500 < now:', this.pressStart + 500 < Date.now())
|
||||
return this.pressStart && (this.pressStart + 500 < Date.now());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,15 +63,16 @@
|
||||
</ion-content>
|
||||
|
||||
|
||||
<ion-toolbar><ion-title>Footer</ion-title></ion-toolbar>
|
||||
<ion-toolbar position="bottom"><ion-title>Footer</ion-title></ion-toolbar>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
input, textarea {
|
||||
border: 1px solid red !important;
|
||||
display: inline-block !important;
|
||||
}
|
||||
|
||||
/*
|
||||
focus-holder input:focus {
|
||||
background: red !important;
|
||||
}
|
||||
@@ -86,7 +87,6 @@
|
||||
|
||||
focus-holder input:nth-child(3) {
|
||||
left: 280px !important;
|
||||
}
|
||||
|
||||
}*/
|
||||
</style>
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ $toolbar-ios-padding: 0px 15px;
|
||||
@include hairline(bottom, $toolbar-ios-border-color);
|
||||
|
||||
// toolbar on bottom, border on top
|
||||
&.toolbar-bottom:after {
|
||||
&[position="bottom"]:after {
|
||||
top: 0;
|
||||
bottom: auto;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,10 @@ ion-toolbar {
|
||||
order: $flex-order-toolbar-top;
|
||||
}
|
||||
|
||||
ion-toolbar[position="bottom"] {
|
||||
order: $flex-order-toolbar-bottom;
|
||||
}
|
||||
|
||||
.toolbar-inner {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
|
||||
Reference in New Issue
Block a user