diff --git a/component.json b/component.json index 0227e0e..a3155a5 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "textarea-caret-position", "repo": "component/textarea-caret-position", - "version": "2.0.0", + "version": "2.1.0", "description": "(x, y) coordinates of the caret in a textarea or input type='text'", "development": { "component/assert": "*" diff --git a/index.js b/index.js index e6d5104..95586b3 100644 --- a/index.js +++ b/index.js @@ -42,7 +42,8 @@ var properties = [ ]; var isFirefox = !(window.mozInnerScreenX == null); -module.exports = function (textarea, position, recalculate) { + +var getCaretCoordinatesFn = function (element, position, recalculate) { // mirrored div var div = document.createElement('div'); div.id = 'input-textarea-caret-position-mirror-div'; @@ -97,3 +98,9 @@ module.exports = function (textarea, position, recalculate) { return coordinates; } + +if (typeof Package !== 'undefined') { + getCaretCoordinates = getCaretCoordinatesFn; // Meteor +} else { + module.exports = getCaretCoordinatesFn; // Component +} diff --git a/test/index.html b/test/index.html index baa8bf9..a7ddfb7 100644 --- a/test/index.html +++ b/test/index.html @@ -5,7 +5,7 @@ input and textarea caret-position testing ground - +

Click anywhere in the text to see a red vertical line – a 1-pixel-thick @@ -41,8 +41,9 @@