1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| <!DOCTYPE html>
<html lang="fr" dir="ltr">
<head>
<meta charset="utf-8">
<title>Insert title here</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.0/themes/sunny/jquery-ui.css">
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.0/jquery-ui.min.js"></script>
<script>
$( function(){
var limite = 50,
widthCarte = $( "#carte" ).innerWidth() - limite,
heightCarte = $( "#carte" ).innerHeight() - limite,
widthDraggable = $( "#draggable" ).outerWidth() - limite,
heightDraggable = $( "#draggable" ).outerHeight() - limite;
$( "#draggable" ).draggable({
"drag" : function( event, ui ){
if ( ( ui.position.top > heightCarte ) ||
( ui.position.left > widthCarte ) ||
( heightDraggable + ui.position.top <= 0 ) ||
( widthDraggable + ui.position.left <= 0 )
) return false;
}
});
});
</script>
<style>
#carte { width: 1000px; height: 700px; overflow: hidden; margin: auto; border:1px solid black; }
#draggable { width: 4100px; height: 2500px; background-image: url("../images/imageTest.png"); }
</style>
</head>
<body>
<p>
<a href="">Déconnexion</a>
</p>
<p>
Bonjour Capitaine bienvenue à bord de votre vaisseau. Quelles sont vos ordre ?
</p>
<div id="carte">
<div id ="draggable"></div>
</div>
</body>
</html> |
Partager