hallo, ich habe vor eine kleine karte zu basteln, aber tu mich irgendwie schon schwer mit nachladen nur auf der x-achse.
habs bis jetzt versucht erstmal irgendwie mit draggable zu meistern. verschiebt man den berreich von rechts nach links, gehts auch so wie ich mir das
vorgestellt habe, aber von links nach rechts gibts probleme. theoretisch gehts, aber praktisch siehts so aus, das sich die tiles um 1 verschieben, da ich einen neuen ganz links anhänge. soll halt so sein das sich nichts verschiebt. hoffe ihr wisst was ich meine.
vielleicht ist der ansatz ne karte mit draggable zu erstellen auch grundlegen falsch? der blaue fixed berreich soll sozusagen der sichtberreich sein. wäre cool wenn mir jemand helfen könnte, oder mich auf den richtigen weg bringen könnte
hier erstmal der code
habs bis jetzt versucht erstmal irgendwie mit draggable zu meistern. verschiebt man den berreich von rechts nach links, gehts auch so wie ich mir das
vorgestellt habe, aber von links nach rechts gibts probleme. theoretisch gehts, aber praktisch siehts so aus, das sich die tiles um 1 verschieben, da ich einen neuen ganz links anhänge. soll halt so sein das sich nichts verschiebt. hoffe ihr wisst was ich meine.
vielleicht ist der ansatz ne karte mit draggable zu erstellen auch grundlegen falsch? der blaue fixed berreich soll sozusagen der sichtberreich sein. wäre cool wenn mir jemand helfen könnte, oder mich auf den richtigen weg bringen könnte
hier erstmal der code
HTML:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<style>
#maincon {
width: 550px;
height:50px;
border: 2px solid #00F;
margin-top: 200px;
margin-left: 300px;
position: fixed;
}
#seewin {
width: 150px;
height:54px;
position: fixed;
margin-top: 200px;
margin-left: 502px;
background-color: #09C;
z-index: 1;
opacity:0.7;
}
#draggable {
height: 48px;
width: 350px;
left: 100px;
border: thin solid #930;
}
#tile1,#tile2,#tile3,#tile4,#tile5,#tile6,#tile7{
height: 46px;
width: 48px;
float:left;
font-size: 20px;
font-weight: bold;
color: #FFF;
background-color: #F00;
border: 1px solid #000;
left: 0px;
}
#tile8,#tile9,#tile10{
height: 46px;
width: 48px;
float:left;
font-size: 20px;
font-weight: bold;
color: #FFF;
background-color: #00F;
border: 1px solid #000;
left: 700px;
display: none;
}
#tile0{
height: 46px;
width: 48px;
float:left;
font-size: 20px;
font-weight: bold;
color: #FFF;
background-color: #00F;
border: 1px solid #000;
display: none;
}
#info {
background-color: #000;
height: 40px;
width: 80px;
position: fixed;
left: 0px;
top: 0px;
color: #FFF;
padding: 5px;
}
</style>
<script>
$(document).ready(function()
{
var a = 0;
$(document).mousemove(function(e){
$('#info1').html(e.pageX +', '+ e.pageY);
var offset = $('#draggable').offset();
$('#info2').text(offset.left + ", " +offset.top);
if(offset.left <360 && a == 0)
{
$("#maincon").css("margin-left", "250px");
$("#maincon").css("width", "650px");
$("#draggable").css("width", "400px");
$("#tile8").show();
a = 1;
}
if(offset.left <310 && a == 1)
{
$("#maincon").css("margin-left", "200px");
$("#maincon").css("width", "750px");
$("#draggable").css("width", "450px");
$("#tile9").show();
a = 2;
}
if(offset.left <260 && a == 2)
{
$("#maincon").css("margin-left", "150px");
$("#maincon").css("width", "850px");
$("#draggable").css("width", "500px");
$("#tile10").show();
a = 3;
}
if(offset.left >460 && a == 0)
{
//$("#maincon").css("margin-left", "250px");
$("#maincon").css("width", "600px");
$("#draggable").css("width", "400px");
$("#tile0").show();
a = 0;
}
});
$('#draggable').draggable( {containment: '#maincon', cursor: 'move'});
});
</script>
</head>
<body>
<div id="seewin"> </div>
<div id="maincon">
<div id="draggable">
<div id="tile0">0</div>
<div id="tile1">1</div>
<div id="tile2">2</div>
<div id="tile3">3</div>
<div id="tile4">E</div>
<div id="tile5">5</div>
<div id="tile6">6</div>
<div id="tile7">7</div>
<div id="tile8">8</div>
<div id="tile9">9</div>
<div id="tile10">10</div>
</div>
</div>
<div id="info"> <div id="info1"></div> <div id="info2"></div></div>
</body>
</html>