diff --git a/src/components/mobile-input/mobile-input.html b/src/components/mobile-input/mobile-input.html index 3def67e..13354ed 100755 --- a/src/components/mobile-input/mobile-input.html +++ b/src/components/mobile-input/mobile-input.html @@ -16,7 +16,8 @@ (blur) = "toggleFocus()" (focus) = "toggleFocus()" (keyup) = "emitChange($event)" - (press) = "onPast()" + (press) = "onPress()" + (pressup) = "onPressUp()" > @@ -33,7 +34,8 @@ [formControl] = "control" [(ngModel)] = "value" (ngModelChange) = "valueChange.emit($event)" - (press) = "onPast()" + (press) = "onPress()" + (pressup) = "onPressUp()" > diff --git a/src/components/mobile-input/mobile-input.ts b/src/components/mobile-input/mobile-input.ts index 7ba8c88..ef64500 100755 --- a/src/components/mobile-input/mobile-input.ts +++ b/src/components/mobile-input/mobile-input.ts @@ -47,6 +47,8 @@ export class MobileInput { valueChange = new EventEmitter(); isFocused = false; + pressedOn = 0; + pastTimeOut; constructor() { @@ -77,7 +79,23 @@ export class MobileInput { } } - onPast(){ + onPressUp(){ + if(Date.now() - this.pressedOn < 1000){ + clearTimeout(this.pastTimeOut); + } + this.pressedOn = 0; + } + + onPress(){ + + this.pressedOn = Date.now(); + this.pastTimeOut = setTimeout(()=>{ + this.paste(); + }, 1000); + + } + + paste(){ Clipboard.paste().then( (resolve: string) => { this.value = resolve; @@ -87,7 +105,6 @@ export class MobileInput { console.error("Unsucessful pasting") } ); - } toggleFocus():void{