473,383 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Simple animation with javascript - IE causes problems

Hey guys!

I'm currently working on project, in which I need to animate a menu. It seems to work all right in Safari and Firefox, but Internet Explorer 7.0 makes the animation run slower, and I can't figure out why!?
So far I have only tested it in version 7.0 of Internet Explorer.

First of all I'll show you the Javascript code, which runs in a seperate document:

Expand|Select|Wrap|Line Numbers
  1. function startSliders(){
  2.  
  3.  
  4.             document.getElementById("menuPunktEt").onclick = function(){
  5.                 if (mayI == true) {
  6.                     if (rightSide == 4) {
  7.                     }
  8.                     else 
  9.                         if (rightSide == 3) {
  10.                             rightSide = 4;
  11.                             leftSide = 0;
  12.                             animate('contentEt', 'contentTo');
  13.                         }
  14.                     if (rightSide == 2) {
  15.                         rightSide = 4;
  16.                         leftSide = 0;
  17.                         animate('contentEt', 'contentTre');
  18.                     }
  19.                     if (rightSide == 1) {
  20.                         rightSide = 4;
  21.                         leftSide = 0;
  22.                         animate('contentEt', 'contentFire');
  23.                     }
  24.                     if (rightSide == 0) {
  25.                         rightSide = 4;
  26.                         leftSide = 0;
  27.                         animate('contentEt', 'forside');
  28.                     }
  29.                 }
  30.             }
  31.             document.getElementById("menuPunktTo").onclick = function(){
  32.                 if (mayI == true) {
  33.                     if (rightSide == 4) {
  34.                         rightSide = 3;
  35.                         leftSide = 1;
  36.                         animate('contentTo', 'contentEt');
  37.                     }
  38.                     else 
  39.                         if (rightSide == 3) {
  40.                         }
  41.                         else 
  42.                             if (rightSide == 2) {
  43.                                 rightSide = 3;
  44.                                 leftSide = 1;
  45.                                 animate('contentTo', 'contentTre');
  46.                             }
  47.                             else 
  48.                                 if (rightSide == 1) {
  49.                                     rightSide = 3;
  50.                                     leftSide = 1;
  51.                                     animate('contentTo', 'contentFire');
  52.                                 }
  53.                                 else 
  54.                                     if (rightSide == 0) {
  55.                                         rightSide = 3;
  56.                                         leftSide = 1;
  57.                                         animate('contentTo', 'forside');
  58.                                     }
  59.                 }
  60.             }
  61.             document.getElementById("menuPunktTre").onclick = function(){
  62.                 if (mayI == true) {
  63.                     if (rightSide == 4) {
  64.                         rightSide = 2;
  65.                         leftSide = 2;
  66.                         animate('contentTre', 'contentEt');
  67.                     }
  68.                     else 
  69.                         if (rightSide == 3) {
  70.                             rightSide = 2;
  71.                             leftSide = 2;
  72.                             animate('contentTre', 'contentTo');
  73.                         }
  74.                         else 
  75.                             if (rightSide == 2) {
  76.                             }
  77.                             else 
  78.                                 if (rightSide == 1) {
  79.                                     rightSide = 2;
  80.                                     leftSide = 2;
  81.                                     animate('contentTre', 'contentFire');
  82.                                 }
  83.                                 else 
  84.                                     if (rightSide == 0) {
  85.                                         rightSide = 2;
  86.                                         leftSide = 2;
  87.                                         animate('contentTre', 'forside');
  88.                                     }
  89.                 }
  90.             }
  91.             document.getElementById("menuPunktFire").onclick = function(){
  92.                 if (mayI == true) {
  93.                     if (rightSide == 4) {
  94.                         rightSide = 1;
  95.                         leftSide = 3;
  96.                         animate('contentFire', 'contentEt');
  97.                     }
  98.                     else 
  99.                         if (rightSide == 3) {
  100.                             rightSide = 1;
  101.                             leftSide = 3;
  102.                             animate('contentFire', 'contentTo');
  103.                         }
  104.                         else 
  105.                             if (rightSide == 2) {
  106.                                 rightSide = 1;
  107.                                 leftSide = 3;
  108.                                 animate('contentFire', 'contentTre');
  109.                             }
  110.                             else 
  111.                                 if (rightSide == 1) {
  112.                                 }
  113.                                 else 
  114.                                     if (rightSide == 0) {
  115.                                         rightSide = 1;
  116.                                         leftSide = 3;
  117.                                         animate('contentFire', 'forside');
  118.                                     }
  119.                 }
  120.             }
  121.         }
  122.  
  123.         function animate(expander, smaller){
  124.             mayI = false;
  125.             bigWindow = expander;
  126.             var slider = document.getElementById(expander);
  127.             var collapse = document.getElementById(smaller);
  128.  
  129.             collapse.style.width = xMinus + "px";
  130.  
  131.             slider.style.width = x + "px";
  132.  
  133.             x += speed;
  134.             xMinus -= speed;
  135.             percent = (lenght - x) / howFar;
  136.             speed = speed * percent;
  137.  
  138.             if (speed > 0.01) {
  139.                 var callFunc = "animate('" + expander + "','" + smaller + "')";
  140.                 setTimeout(callFunc, 1);
  141.             }
  142.             else {
  143.                 mayI = true;
  144.                 x = 0;
  145.                 xMinus = 694;
  146.                 speed = 30;
  147.                 lenght = 8260;
  148.                 howFar = lenght - x;
  149.                 percent = 0;
  150.  
  151.             }
  152.         }
  153.  

And here comes the html-code:


[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Hummel - You've got game</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jscript.js"></script>
<script type="text/javascript">
var x = 0,xMinus = 695,speed = 30,lenght = 8260,howFar = lenght-x,percent,small,rightSide = 0,leftSide = 4,mayI = true;
window.onload = function() {
startSliders();}
</script>
</head>
<body>
<div id="wrapper">
<div id="shadowTop"></div>
<div id="shadowLeft"></div>
<div id="content">
<div id="contentEt"></div>
<div id="menuPunktEt"></div>
<div id="contentTo"></div>
<div id="menuPunktTo"></div>
<div id="contentTre"></div>
<div id="menuPunktTre"></div>
<div id="contentFire"></div>
<div id="menuPunktFire"></div>
<div id="forside"></div>

</div>
<div id="shadowRight"></div>
<div id="footer"><p class="whiteText">Copyright by J I, M N & N B</p></div>
</div>
</body>
</html>[/HTML]
Mar 29 '08 #1
1 1432
acoder
16,027 Expert Mod 8TB
The memory leak is probably caused by a circular reference. See if this link helps.
Apr 1 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Arne Nordmann | last post by:
hi, there is an animation, that animates the x-attribute of my element from 0 to 300 within 6 seconds. there a two buttons, that manipulate the dur-attribute of the animation to 3 or 9 seconds....
6
by: Reid Goldsborough | last post by:
Hi. I'm a JavaScript neophyte. I'm trying to create a JPEG animation, with one coin (tet) morphing into another. The code doesn't work. Anybody feel like taking a shot at correcting me? It's short....
2
by: billrdio | last post by:
I am trying to make a JavaScript animation of real-time images - i.e. images that will periodically change on the server. The problem I am having is that the JavaScript animation I have created is...
6
by: J. J. Cale | last post by:
Hi all I get different speeds from this animation in IE6 and Mozilla. Mozilla 1.7.3 runs this much faster than IE . I'm trying to get the results that Mozilla returns. IE is too slow!! Anyone...
5
by: Don Lancaster | last post by:
I am conjuring up some simple JavaScript animation routies that work entirely WITHIN Acrobat .PDF files. They work very well but they are waay too fast! And are also CPU speed dependent. I...
5
by: wmschneider | last post by:
I am trying to make a progress animation so that the user knows that there files are correctly being checked in. Trying to animate papers moving from the computer to the server pics. I'm brand...
12
by: mantrid | last post by:
Can anyone see why this simple script doesnt make the element visible? It starts of as hidden but will not show when the button is clicked. This has worked for me before but I cannot see what is...
1
by: softwaredeveloper | last post by:
Hi friends, I am very new here, could you please give me some suggestions? Is FLASH the right technology? Or if there is any better solution? Purpose - To generate multiple simple moving...
2
by: jasonchan | last post by:
I am trying to have a function start with a timer and then switch to another function. However, it is not working at all. Anyone know whats goin on? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.