If you can't visit the site, then here's the full code:
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Transition</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link href="CSS\jquery-ui.css" rel="stylesheet" />
<link href="CSS\jquery-ui.structure.css" rel="stylesheet" />
<link href="CSS\jquery-ui.theme.css" rel="stylesheet" />
<script src="Script\jquery-1.11.1.min.js"></script>
<script src="Script\jquery-ui.min.js"></script>
<style>
.transitionWidthClass{
-webkit-transition: width 1s ease-in;
-moz-transition: width 1s ease-in;
-o-transition: width 1s ease-in;
transition: width 1s ease-in;
}
.smallWidthClass{
display: inline-block;
width: 100px;
}
.bigWidthClass
{
display: inline-block;
width: 200px;
}
.hiddenWidthClass
{
display: inline-block;
width: 0px;
}
.transitionHeightClass{
-webkit-transition: height 1s ease-in;
-moz-transition: height 1s ease-in;
-o-transition: height 1s ease-in;
transition: height 1s ease-in;
}
.smallHeightClass{
display: inline-block;
height: 100px;
}
.bigHeightClass
{
display: inline-block;
height: 200px;
}
.hiddenHeightClass
{
display: inline-block;
height: 0px;
}
</style>
</head>
<body style="text-align: center;">
<table style="width: 100%; height: 100vh;" border="1">
<tr>
<td style="width: 50%;">
<div id="LeftDiv" class="transitionWidthClass smallWidthClass" style="display: inline-block; background-color: green; height: 200px; border: 3px blue solid; border-radius: 4px;">
</div>
<br/>
<br/>
<br/>
<input type="button" value="Hide" onclick="LeftHideButton_Click();"/>
<br/>
<input type="button" value="Small" onclick="LeftSmallButton_Click();"/>
<br/>
<input type="button" value="Big" onclick="LeftBigButton_Click();"/>
</td>
<td style="width: 50%;">
<div id="RightDiv" class="transitionHeightClass smallHeightClass" style="display: inline-block; background-color: red; width: 200px; border: 3px blue solid; border-radius: 4px;">
</div>
<br/>
<br/>
<br/>
<input type="button" value="Hide" onclick="RightHideButton_Click();"/>
<br/>
<input type="button" value="Small" onclick="RightSmallButton_Click();"/>
<br/>
<input type="button" value="Big" onclick="RightBigButton_Click();"/>
</td>
</tr>
</table>
<script>
$(document).ready(function() {
$(window).on("webkitTransitionEnd", function(event)
{
$(".hiddenWidthClass").hide();
$(".hiddenHeightClass").hide();
});
});
var LeftHideButton_Click = function()
{
$("#LeftDiv").removeClass("smallWidthClass").removeClass("bigWidthClass");
$("#LeftDiv").addClass("hiddenWidthClass");
};
var LeftSmallButton_Click = function()
{
$("#LeftDiv").show();
$("#LeftDiv").removeClass("bigWidthClass").removeClass("hiddenWidthClass");
$("#LeftDiv").addClass("smallWidthClass");
};
var LeftBigButton_Click = function()
{
$("#LeftDiv").show();
$("#LeftDiv").removeClass("smallWidthClass").removeClass("hiddenWidthClass");
$("#LeftDiv").addClass("bigWidthClass");
};
var RightHideButton_Click = function()
{
$("#RightDiv").removeClass("smallHeightClass").removeClass("bigHeightClass");
$("#RightDiv").addClass("hiddenHeightClass");
};
var RightSmallButton_Click = function()
{
$("#RightDiv").show();
$("#RightDiv").removeClass("bigHeightClass").removeClass("hiddenHeightClass");
$("#RightDiv").addClass("smallHeightClass");
};
var RightBigButton_Click = function()
{
$("#RightDiv").show();
$("#RightDiv").removeClass("smallHeightClass").removeClass("hiddenHeightClass");
$("#RightDiv").addClass("bigHeightClass");
};
</script>
</body>
</html>
I have some jquery references in there, so if you want to try this yourself, you'll have to provide those yourself.
In any case, here's a couple example functions. First the hide fuction:
var RightHideButton_Click = function()
{
$("#RightDiv").removeClass("smallHeightClass").removeClass("bigHeightClass"); // <-- remove the small and big classes
$("#RightDiv").addClass("hiddenHeightClass"); // <-- add the hide class (just sets the height to 0)
};
So this function gets called when you click the hide button. It transitions from height: 100px (if it has the smallHeightClass) or 200px (if it has the bigHeightClass) to height: 0 (by being given the hiddenHeightClass). It then hides the div (Calling .Hide()) in the webkitTransitionEnd event handler.
This works pretty smoothly.
Note that it's the height/width that I'm trying to transition, not the opacity (although setting opacity to 0 in the webkitTransitionEnd event handler instead of calling .hide() might work).
After it's been hidden, I want to do the reverse process: I want to show it, then transition to the "small" or "big" size (which ever button gets clicked).
Here's an example:
var RightBigButton_Click = function()
{
$("#RightDiv").show(); // <-- Make the div visible again
$("#RightDiv").removeClass("smallHeightClass").removeClass("hiddenHeightClass"); // <-- remove the small and hidden classes
$("#RightDiv").addClass("bigHeightClass"); // <-- Add the big class
};
This is what's not working. You would think, according to the sequence of steps above, that the div would first become visible (just a flat line) and then expand to height: 200px. But this is not what happens. It becomes visible already at height: 200px. It skips the transition.
Bookmarks