PDA

View Full Version : IE problem



mikkelwh
01-28-2011, 05:36 PM
Hi, i can't get my new logo to work in IE, it's working fine in Chrome and FireFox, it must be a JavaScript problem.

here it is:
http://danishwebart.com/logo/logo.php

And the JavaScrip:

$(function() {
var canvas = $("#c");
var canvasHeight;
var canvasWidth;
var ctx;
var dt = 0.1;

var pointCollection;

function init() {
updateCanvasDimensions();

var g = [new Point(27, 34, 0.0, 1, "#ed9d33"), new Point(26, 38, 0.0, 1, "#d44d61"), new Point(25, 41, 0.0, 1, "#4f7af2"), new Point(22, 44, 0.0, 1, "#ef9a1e"), new Point(18, 46, 0.0, 2, "#4976f3"), new Point(12, 44, 0.0, 2.5, "#269230"), new Point(7, 41, 0.0, 2, "#1f9e2c"), new Point(5, 37, 0.0, 1, "#36b641"), new Point(4, 33, 0.0, 1, "#2e5def"), new Point(4, 29, 0.0, 1, "#d53747"), new Point(5, 25, 0.0, 1, "#eb676f"), new Point(6, 22, 0.0, 1, "#f9b125"), new Point(8, 19, 0.0, 1, "#de3646"), new Point(11, 16, 0.0, 1, "#5f8af8"), new Point(13, 14, 0.0, 1, "#efa11e"), new Point(16, 12, 0.0, 1, "#2e55e2"), new Point(19, 10, 0.0, 1, "#4167e4"), new Point(23, 8, 0.0, 1.5, "#4869e3"), new Point(28, 6, 0.0, 2, "#10a11d"), new Point(33, 5, 0.0, 2, "#cf4055"), new Point(38, 5, 0.0, 2, "#cd4359"), new Point(44, 6, 0.0, 3, "#ca273c"), new Point(51, 8, 0.0, 3, "#2650e1"), new Point(57, 11, 0.0, 3, "#4a7bf9"), new Point(63, 16, 0.0, 3.5, "#f47875"), new Point(68, 23, 0.0, 4, "#f36764"), new Point(71, 31, 0.0, 3.5, "#1d4eeb"), new Point(72, 38, 0.0, 3, "#698bf1"), new Point(72, 44, 0.0, 2.5, "#fac652"), new Point(72, 49, 0.0, 2, "#ee5257"), new Point(71, 54, 0.0, 2, "#5681f5"), new Point(70, 59, 0.0, 2, "#f8c247"), new Point(68, 64, 0.0, 2, "#4577f6"), new Point(65, 68, 0.0, 2, "#f7b326"), new Point(62, 72, 0.0, 2, "#facb5e"), new Point(59, 75, 0.0, 2, "#e02e3d"), new Point(55, 77, 0.0, 2, "#f16d6f"), new Point(53, 78, 0.0, 2.5, "#507bf2"), new Point(47, 79, 0.0, 3, "#5683f7"), new Point(40, 77, 0.0, 3.5, "#3158e2"), new Point(33, 74, 0.0, 3.5, "#f0696c"), new Point(27, 73, 0.0, 2.5, "#3769f6"), new Point(22, 73, 0.0, 2, "#6084ef"), new Point(19, 76, 0.0, 1.5, "#2a5cf4"), new Point(17, 79, 0.0, 1, "#f4716e"), new Point(25, 70, 0.0, 2, "#f8c247"), new Point(29, 67, 0.0, 2, "#ec4147"), new Point(33, 64, 0.0, 2, "#4876f1"), new Point(36, 59, 0.0, 2.5, "#2552ea"), new Point(38, 53, 0.0, 3, "#4779f7"), new Point(38, 46, 0.0, 3.5, "#4b78f1"), new Point(38, 38, 0.0, 3.5, "#4b78f1"), new Point(37, 31, 0.0, 2.5, "#4b78f1"), new Point(38, 25, 0.0, 2, "#4b78f1"), new Point(40, 20, 0.0, 2, "#4b78f1"), new Point(42, 16, 0.0, 1.5, "#4b78f1"), new Point(45, 14, 0.0, 1, "#4b78f1"), new Point(48, 12, 0.0, 1, "#4b78f1"),




new Point(59, 82, 0.0, 1, "#ed9d33"), new Point(62, 80, 0.0, 1.5, "#d44d61"), new Point(66, 77, 0.0, 2, "#4f7af2"), new Point(70, 73, 0.0, 2, "#4976f3"), new Point(73, 69, 0.0, 2, "#269230"), new Point(76, 65, 0.0, 2, "#1f9e2c"), new Point(79, 60, 0.0, 2, "#36b641"), new Point(80, 55, 0.0, 1.5, "#2e5def"),

new Point(81, 65, 0.0, 2.5, "#eb676f"), new Point(83, 71, 0.0, 3, "#f9b125"), new Point(84, 77, 0.0, 2.5, "#de3646"), new Point(82, 82, 0.0, 2, "#de3646"),

new Point(88, 74, 0.0, 1.5, "#efa11e"), new Point(90, 70, 0.0, 1.5, "#2e55e2"), new Point(92, 66, 0.0, 1.5, "#4869e3"), new Point(93, 62, 0.0, 1.5, "#4869e3"),

new Point(95, 53, 0.0, 1, "#10a11d"), new Point(95, 57, 0.0, 2, "#cf4055"), new Point(97, 62, 0.0, 2.5, "#cd4359"), new Point(100, 68, 0.0, 3, "#ca273c"), new Point(102, 74, 0.0, 2.5, "#2650e1"), new Point(101, 80, 0.0, 2, "#4a7bf9"),

new Point(105, 78, 0.0, 1, "#f36764"), new Point(107, 75, 0.0, 1, "#1d4eeb"), new Point(109, 72, 0.0, 1, "#698bf1"), new Point(110, 69, 0.0, 1, "#fac652"), new Point(111, 66, 0.0, 1, "#ee5257"), new Point(112, 63, 0.0, 1, "#5681f5"), new Point(112, 60, 0.0, 1.5, "#f8c247"), new Point(112, 56, 0.0, 1.5, "#4577f6"), new Point(110, 52, 0.0, 2, "#f7b326"), new Point(107, 48, 0.0, 2.5, "#facb5e"), new Point(102, 45, 0.0, 2.5, "#e02e3d"), new Point(97, 43, 0.0, 2, "#f16d6f"),




new Point(110, 83, 0.0, 1, "#507bf2"), new Point(112, 80, 0.0, 1, "#5683f7"), new Point(114, 77, 0.0, 1.5, "#3158e2"), new Point(116, 73, 0.0, 1.5, "#f0696c"), new Point(118, 69, 0.0, 1.5, "#3769f6"), new Point(119, 65, 0.0, 1.5, "#6084ef"), new Point(119, 61, 0.0, 1.5, "#2a5cf4"), new Point(119, 57, 0.0, 1.5, "#f4716e"), new Point(118, 53, 0.0, 1.5, "#f8c247"), new Point(116, 50, 0.0, 1, "#ec4147"),

new Point(120, 51, 0.0, 1, "#4876f1"), new Point(123, 53, 0.0, 1, "#2552ea"), new Point(126, 55, 0.0, 1, "#4779f7"), new Point(129, 58, 0.0, 1.5, "#4b78f1"), new Point(132, 61, 0.0, 1.5, "#4b78f1"), new Point(135, 65, 0.0, 1.5, "#4b78f1"), new Point(138, 69, 0.0, 1.5, "#4b78f1"), new Point(140, 73, 0.0, 2, "#4b78f1"), new Point(142, 78, 0.0, 2, "#4b78f1"), new Point(143, 83, 0.0, 2, "#4b78f1"),

new Point(121, 70, 0.0, 1, "#4b78f1"), new Point(124, 71, 0.0, 1, "#4b78f1"), new Point(127, 71, 0.0, 1, "#4b78f1"), new Point(130, 71, 0.0, 1.5, "#4b78f1"), new Point(134, 70, 0.0, 1.5, "#4b78f1"), new Point(142, 68, 0.0, 1.5, "#4b78f1"), new Point(146, 68, 0.0, 1, "#4b78f1"), new Point(149, 69, 0.0, 1, "#4b78f1")];

gLength = g.length;
for (var i = 0; i < gLength; i++) {
g[i].curPos.x = (canvasWidth/2 - 0) + g[i].curPos.x;
g[i].curPos.y = (canvasHeight/2 - 0) + g[i].curPos.y;

g[i].originalPos.x = (canvasWidth/2 - 0) + g[i].originalPos.x;
g[i].originalPos.y = (canvasHeight/2 - 0) + g[i].originalPos.y;
};

pointCollection = new PointCollection();
pointCollection.points = g;

initEventListeners();
timeout();
};

function initEventListeners() {
$(window).bind('resize', updateCanvasDimensions).bind('mousemove', onMove);

canvas.get(0).ontouchmove = function(e) {
e.preventDefault();
onTouchMove(e);
};

canvas.get(0).ontouchstart = function(e) {
e.preventDefault();
};
};

function updateCanvasDimensions() {
canvas.attr({height: $(window).height(), width: $(window).width()});
canvasWidth = canvas.width();
canvasHeight = canvas.height();

draw();
};

function onMove(e) {
if (pointCollection)
pointCollection.mousePos.set(e.pageX, e.pageY);
};

function onTouchMove(e) {
if (pointCollection)
pointCollection.mousePos.set(e.targetTouches[0].pageX, e.targetTouches[0].pageY);
};

function timeout() {
draw();
update();

setTimeout(function() { timeout() }, 30);
};

function draw() {
var tmpCanvas = canvas.get(0);

if (tmpCanvas.getContext == null) {
return;
};

ctx = tmpCanvas.getContext('2d');
ctx.clearRect(0, 0, canvasWidth, canvasHeight);

if (pointCollection)
pointCollection.draw();
};

function update() {
if (pointCollection)
pointCollection.update();
};

function Vector(x, y, z) {
this.x = x;
this.y = y;
this.z = z;

this.addX = function(x) {
this.x += x;
};

this.addY = function(y) {
this.y += y;
};

this.addZ = function(z) {
this.z += z;
};

this.set = function(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
};
};

function PointCollection() {
this.mousePos = new Vector(0, 0);
this.points = new Array();

this.newPoint = function(x, y, z) {
var point = new Point(x, y, z);
this.points.push(point);
return point;
};

this.update = function() {
var pointsLength = this.points.length;

for (var i = 0; i < pointsLength; i++) {
var point = this.points[i];

if (point == null)
continue;

var dx = this.mousePos.x - point.curPos.x;
var dy = this.mousePos.y - point.curPos.y;
var dd = (dx * dx) + (dy * dy);
var d = Math.sqrt(dd);

if (d < 80) {
point.targetPos.x = (this.mousePos.x < point.curPos.x) ? point.curPos.x - dx : point.curPos.x - dx;
point.targetPos.y = (this.mousePos.y < point.curPos.y) ? point.curPos.y - dy : point.curPos.y - dy;
} else {
point.targetPos.x = point.originalPos.x;
point.targetPos.y = point.originalPos.y;
};

point.update();
};
};

this.draw = function() {
var pointsLength = this.points.length;
for (var i = 0; i < pointsLength; i++) {
var point = this.points[i];

if (point == null)
continue;

point.draw();
};
};
};

function Point(x, y, z, size, colour) {
this.colour = colour;
this.curPos = new Vector(x, y, z);
this.friction = 0.8;
this.originalPos = new Vector(x, y, z);
this.radius = size;
this.size = size;
this.springStrength = 0.1;
this.targetPos = new Vector(x, y, z);
this.velocity = new Vector(0.0, 0.0, 0.0);

this.update = function() {
var dx = this.targetPos.x - this.curPos.x;
var ax = dx * this.springStrength;
this.velocity.x += ax;
this.velocity.x *= this.friction;
this.curPos.x += this.velocity.x;

var dy = this.targetPos.y - this.curPos.y;
var ay = dy * this.springStrength;
this.velocity.y += ay;
this.velocity.y *= this.friction;
this.curPos.y += this.velocity.y;

var dox = this.originalPos.x - this.curPos.x;
var doy = this.originalPos.y - this.curPos.y;
var dd = (dox * dox) + (doy * doy);
var d = Math.sqrt(dd);

this.targetPos.z = d/100 + 1;
var dz = this.targetPos.z - this.curPos.z;
var az = dz * this.springStrength;
this.velocity.z += az;
this.velocity.z *= this.friction;
this.curPos.z += this.velocity.z;

this.radius = this.size*this.curPos.z;
if (this.radius < 1) this.radius = 1;
};

this.draw = function() {
ctx.fillStyle = this.colour;
ctx.beginPath();
ctx.arc(this.curPos.x, this.curPos.y, this.radius, 0, Math.PI*2, true);
ctx.fill();
};
};

init();
});

xelawho
01-29-2011, 01:32 AM
far as I am aware, IE doesn't support canvases :(

EDIT: I take that back - IE9 joins the party. read more here (http://www.canvasdemos.com/2010/06/29/internet-explorer-9-supports-canvas/)

stifenhugs
01-29-2011, 02:04 PM
In short IE6 and lower have problems in computing/honoring the width of block elements that contain italic text. In its simplest form the problem can be seen here

mikkelwh
01-29-2011, 05:31 PM
So i just have to wait for everybody to swap from IE7 / IE8 to IE9. :eek:

I just love IE.......NOT :(

But thanks anyway.

xelawho
01-29-2011, 05:54 PM
I use a little piece of code here (http://xelawho.com/bus/) which sets up a test canvas, checks to see if the browser can read it and if not goes off onto a different function. Maybe you could use something similar (and hope that the world sees the light sometime soon)

Old Pedant
01-29-2011, 08:24 PM
Except in this case, I wouldn't go to all that work using a canvas, in the first place.

Just use two images: One with the small dots and one with the brighter, larger dots.

Fade from the small to the large to get the "bloom" effect and then fade back to the small for the stable image. That will work in all browsers, even going way way back, and be much more efficient than what is surely a fairly slow and tedious drawing process on the canvas. No?

mikkelwh
01-30-2011, 12:00 PM
Old Pedant:
All sounds good, but I can only edit a little bit in Javascript, this codes are not written by me.

There must be a IE fix for canvas, i just install IE9 BETA, and it still don't work.