Fix Float32Array bug in IE. Fix input selection bug in IE.

This commit is contained in:
evancz 2013-05-22 14:05:53 +02:00
parent d9d6ce51ca
commit 582a4c5ee2
3 changed files with 30 additions and 5 deletions

View file

@ -140,6 +140,14 @@ Elm.Native.Graphics.Input = function(elm) {
return { _:{}, box:F2(box), events:events };
}
function setRange(node, start, end, dir) {
if (node.parentNode) {
node.setSelectionRange(start, end, dir);
} else {
setTimeout(function(){node.setSelectionRange(start, end, dir);}, 0);
}
}
function mkTextPool(type) { return function fields(defaultValue) {
var events = Signal.constant(defaultValue);
@ -153,7 +161,7 @@ Elm.Native.Graphics.Input = function(elm) {
field.type = type;
field.placeholder = fromString(model.placeHolder);
field.value = fromString(model.state.string);
field.setSelectionRange(model.state.selectionStart, model.state.selectionEnd);
setRange(field, model.state.selectionStart, model.state.selectionEnd, 'forward');
field.style.border = 'none';
state = model.state;
@ -202,7 +210,7 @@ Elm.Native.Graphics.Input = function(elm) {
if (node.selectionStart !== start
|| node.selectionEnd !== end
|| node.selectionDirection !== direction) {
node.setSelectionRange(start, end, direction);
setRange(node, start, end, direction);
}
}

View file

@ -5,8 +5,20 @@ Elm.Native.Matrix2D = function(elm) {
elm.Native = elm.Native || {};
if (elm.Native.Matrix2D) return elm.Native.Matrix2D;
if (typeof Float32Array === 'undefined'){ Float32Array = Array; }
var A = Float32Array;
var A;
if (typeof Float32Array === 'undefined') {
A = function(arr) {
this.length = arr.length;
this[0] = arr[0];
this[1] = arr[1];
this[2] = arr[2];
this[3] = arr[3];
this[4] = arr[4];
this[5] = arr[5];
};
} else {
A = Float32Array;
}
// layout of matrix in an array is
//

View file

@ -279,7 +279,12 @@ function updateTracker(w,h,div) {
if (!container) {
div.appendChild(container);
} else {
div.insertBefore(container, kids[i]);
var kid = kids[i];
if (kid) {
div.insertBefore(container, kid);
} else {
div.appendChild(container);
}
}
}
// we have added a new node, so we must step our position