Jump to content
Search Community

Tweening CSS width dont work in Firefox but everywere else

Hajad test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

This work in IE, Safari, Opera, Chrome but NOT in Safari. Any advice?

 

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="TweenMax.min.js"></script>
<style type="text/css">
body {
margin:0px;
}
p{
background-color:#ff0000;
width:300px;
padding:2px;
text-align:center;
position:absolute;

}
</style>
<script type="text/javascript">
var rullaPa;
var rullaAv;
var pElementet;
function testar() {
pElementet = document.getElementById("p1");
pElementet.addEventListener("mouseover", rullaPa, false);
pElementet.addEventListener("mouseout", rullaAv, false);
 }
 function rullaPa() {
 TweenMax.to(p1, 2,{css: {width:"400px"}});
document.getElementById("p1").innerHTML = "Rullat på";
}

function rullaAv() {
 TweenMax.to(p1, 2,{css: {width:"300px"}});
 document.getElementById("p1").innerHTML = "Rullat av";
}
window.onload = testar;
   </script>
    </head>
    <body>
    <p id="p1">Byt text med olika JavaScript händelser</p>
    </body>
    </html>

Link to comment
Share on other sites

This work in IE, Safari, Opera, Chrome but NOT in Safari. Any advice?

 

Sorry to have wasted your time. I should have referenced to the variabel - pElementet - instead of the id of - p1 -. This work (se code) but still wonder why the former worked in all browsers but Firefox, Hmm?

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="TweenMax.min.js"></script>
<style type="text/css">
body {
margin:0px;
}
p{
background-color:#ff0000;
width:300px;
padding:2px;
text-align:center;
position:absolute;

}
</style>
<script type="text/javascript">
var rullaPa;
var rullaAv;
var pElementet;
function testar() {
pElementet = document.getElementById("p1");
pElementet.addEventListener("mouseover", rullaPa, false);
pElementet.addEventListener("mouseout", rullaAv, false);
 }
 function rullaPa() {
 TweenMax.to(pElementet, 2,{css: {width:"400px"}});
document.getElementById("p1").innerHTML = "Rullat på";
}

function rullaAv() {
 TweenMax.to(pElementet, 2,{css: {width:"300px"}});
 document.getElementById("p1").innerHTML = "Rullat av";
}
window.onload = testar;
</script>
	</head>
	<body>
	<p id="p1">Byt text med olika JavaScript händelser</p>
	</body>
	</html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...