So I'm trying to follow the code for ramjet http://www.rich-harris.co.uk/ramjet/ , but I can't get element a to disappear while moving into b. I also get --Uncaught TypeError: Cannot read property 'add' of undefined--. Element a does move, though. How can I get a to turn into b, as shown on the page.
Script.js
$(document).ready( function() {
// set the stage so ramjet copies the right styles...
b.classList.remove('hidden');
ramjet.transform( a, b, {
done: function () {
// this function is called as soon as the transition completes
b.classList.remove('hidden');
}
});
// ...then hide the original elements for the duration of the transition
a.classList.add('hidden');
b.classList.add('hidden');
});
index.html
<!DOCTYPE HTML>
<html>
<head>
<link type="text/css" rel="stylesheet" href="stylesheet.css" />
<script src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="./ramjet.js"></script>
<script type="text/javascript" src="./script.js"></script>
</head>
<body>
<div class="back">
<div id="a"></div>
<div id="b" class="hidden"></div>
</div>
</body>
</html>
stylesheet.css
.back {
float: left;
width: 790px;
height: 525px;
border-radius: 5px;
background-color: #BCD2EE
}
#a {
margin: 200px 10px;
margin-right: auto;
width: 175px;
height: 60px;
background-color: #666699;
display: inline-block;
position: relative;
border: 2px solid black;
}
#b {
margin: 200px 10px;
margin-right: auto;
width: 175px;
height: 60px;
background-color: red;
display: inline-block;
position: relative;
border: 2px solid black;
}
.hidden {
visibility: hidden;
}
here is the script in my head tag:
<script type="text/javascript" src="jquery-1.11.1.js"></script>
<script type="text/javascript" src="ramjet.js"></script>
<script type="text/javascript">
$(document).ready( function() {
// set the stage so ramjet copies the right styles...
b.classList.remove('hidden');
ramjet.transform( a, b, {
done: function () {
// this function is called as soon as the transition completes
b.classList.remove('hidden');
}
});
// ...then hide the original elements for the duration of the transition
a.classList.add('hidden');
b.classList.add('hidden');
});
</script>
no change in css the code works fine. the div b got hide and div a acquire the property of b.
i think the problem is in your script path the you define in your docs head section. check your path.
before changing my div a looks like this. after the DOM get loads it turns and acquire the property of div b as red:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.