473,839 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple animation with javascript - IE causes problems

4 New Member
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="menuPunktTr e"></div>
<div id="contentFire "></div>
<div id="menuPunktFi re"></div>
<div id="forside"></div>

</div>
<div id="shadowRight "></div>
<div id="footer"><p class="whiteTex t">Copyright by J I, M N & N B</p></div>
</div>
</body>
</html>[/HTML]
Mar 29 '08 #1
1 1461
acoder
16,027 Recognized Expert Moderator MVP
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
1844
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. the problem: if i click on one of these buttons, the position of my element is set to that x-position, the element would have, if the animation would have run all the time at that speed. but i want, that the animation
6
3126
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. Here it is: <HTML> <HEAD> <TITLE>Thracian tetradrachm animation</TITLE>
2
2123
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 always using the images from the cache, even though I have set the HTTP response header on the server (via .htaccess) so that the browser should validate the image in the cache against the image on the server for freshness. I have tested the...
6
1872
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 know why? Is my code flawed and one browser is interpreting it correctly? Any help will be appreciated. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <HTML><HEAD><TITLE>Animate Card test</TITLE>
5
7159
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 want to present each page "cell" for, say, 50 milliseconds. This "too fast" JavaScript set page action code works fine ..
5
2109
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 new at this language, however, I've been programming in C++ for awhile. This is my code for that part of it. And I call the startAnimation() function when the button finish is clicked on. Represented like: <INPUT TYPE="SUBMIT" NAME="SUBMIT"...
12
1428
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 different. Thanks <script language="Javascript">
1
1785
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 objects like a box on my website that can move from left to right and up/down. The moving objects have to be dynamically generated according to different products and the sharps are a little bit different.
2
1852
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 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script...
0
9855
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10587
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10295
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9426
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7829
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7018
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3136
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.