From bc9bcdd6788947091937d5f10011c7bf88cf8ee0 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Thu, 4 Feb 2016 11:25:00 -0800 Subject: [PATCH] Adds explanations on textarea styling #143 #179 #180 --- src/clipboard-action.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/clipboard-action.js b/src/clipboard-action.js index 03bb5f10..38875b45 100644 --- a/src/clipboard-action.js +++ b/src/clipboard-action.js @@ -58,11 +58,16 @@ export default class ClipboardAction { this.fakeHandler = document.body.addEventListener('click', () => this.removeFake()); this.fakeElem = document.createElement('textarea'); + // Prevent zooming on iOS + this.fakeElem.style.fontSize = '12pt'; + // Reset box model + this.fakeElem.style.border = '0'; this.fakeElem.style.padding = '0'; this.fakeElem.style.margin = '0'; + // Move element out of screen horizontally this.fakeElem.style.position = 'absolute'; - this.fakeElem.style.fontSize = '12pt'; // Prevent zooming on iPhones. this.fakeElem.style[ isRTL ? 'right' : 'left' ] = '-9999px'; + // Move element to the same position vertically this.fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px'; this.fakeElem.setAttribute('readonly', ''); this.fakeElem.value = this.text;