Touch Punch не работает
Я делаю приложение HTML5 с помощью jQuery Mobile, и я просто добавил в приложение возможность сенсорного удара. Веб-сайт ( http://touchpunch.furf.com/) прекрасно работает в моем мобильном телефоне, но когда я пытаюсь применить те же методы в своем приложении, функция перетаскивания не работает правильно.
Вот моя глава кода, так что вы, ребята, можете проверить, правильно ли я вставляю исходные коды jquery.
<head>
<title>Parking Lot App</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="themes/florida_tech.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile.structure-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
<script src="jquery.ui.touch-punch.min.js"></script> <!-- TOUCH PUNCH -->
</head>
Это код, где отображается контент. Это просто изображение с 2 зелеными блоками внутри div
<div data-role="content" style="margin:0px; padding:0px; border:0px">
<div id="draggable" class="ui-widget-content" style="position:relative; height: 347px">
<div style=" position: absolute; top: 0px; left: 0px">
<img src="style/pic.png" alt="Parking Lot Map"/>
</div>
<div style="background-color:green; width:17px; height:35px; z-index: 2; position: absolute; top: 31px; left: 81px ">
 
</div>
<div style="background-color:green; width:17px; height:35px; z-index: 2; position: absolute; top: 31px; left: 102px ">
 
</div>
</div>
1 ответ
Возможно, библиотека jQueryUI и библиотека jQuery Mobile конфликтуют друг с другом. Я сделал пример кода из вашего кода:
<html>
<head>
<title>Parking Lot App</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!--<link rel="stylesheet" href="themes/florida_tech.min.css" />-->
<!--<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile.structure-1.3.1.min.css" />-->
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
<script src="jquery.ui.touch-punch.min.js"></script>
</head>
<body>
<div data-role="content" style="margin:0px; padding:0px; border:0px">
<div id="draggable" class="ui-widget-content" style="position:relative; height: 347px">
<div style=" position: absolute; top: 0px; left: 0px">
<img src="style/pic.png" alt="Parking Lot Map"/>
</div>
<div style="background-color:green; width:17px; height:35px; z-index: 2; position: absolute; top: 31px; left: 81px "> </div>
<div style="background-color:green; width:17px; height:35px; z-index: 2; position: absolute; top: 31px; left: 102px "> </div>
</div>
</div>
<script>
$('#draggable').draggable();
</script>
</body>
</html>
Этот код работает на моем iPad mini(iOS6) и браузерах для ноутбуков (Chrome, Safari и т. Д.). В приведенном выше коде я закомментировал таблицы стилей ("themes/florida_tech.min.css" и " http://code.jquery.com/mobile/1.3.1/jquery.mobile.structure-1.3.1.min.css"). В моей среде jquery.mobile.structure-1.3.1.min.css может конфликтовать с jQueryUI. Когда я закомментировал эту таблицу стилей, все работало хорошо.