我怎么能把这个代码放在移动设备上运行
how i can put this code running on mobile devicds?
我想在我的手机上运行这个代码,但如果我试图移动图片,它不会移动,也没有反应,我如何才能让这个代码在移动上运行
感谢der122345
copy = 1;
$('.dragArea img').on('dragstart',function(e) {
console.log('dragge it!',e);
e.originalEvent.dataTransfer.setData("text",e.target.id);
}).on('dragend',function(e) {
console.log('dragged',e);
});
$('.drop-field').on('dragover',function(e) {
//console.log('dragover',e);
e.preventDefault();
}).on('drop',function(e) {
e.preventDefault();
//window.status = 'successfully dragged';
console.log('drop',e,window.status);
data = e.originalEvent.dataTransfer.getData("text");
$(this).append(copy ? $('#' + data).clone() : $('#' + data));
});
.drop-field {
border: 4px #287CA1 dashed;
display: inline-block;
min-width: 50px;
height: 50px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="dragArea">
<img src="http://lorempixel.com/image_output/city-q-g-640-480-4.jpg" width="50" height="50" alt="logo" id="logo" />
</div>
<div class="dropArea">
<span class="drop-field"></span>
<span class="drop-field"></span>
</div>
移动设备不支持本地拖放。您将需要求助于任一:
-
触摸API,使用
touchmove
和touchend
:el.addEventListener("touchstart", handleStart, false); el.addEventListener("touchend", handleEnd, false); el.addEventListener("touchcancel", handleCancel, false); el.addEventListener("touchmove", handleMove, false);
-
仅支持iOS的拖放填充程序。
-
或者jQuery UI可通过Touch Punch拖动。
这实际上完全取决于你想要什么样的浏览器支持,以及你愿意重写多少代码。
相关文章:
- 如何使用phaser使html5游戏在移动设备浏览器上运行
- 我怎么能把这个代码放在移动设备上运行
- 如何防止脚本在移动设备上运行
- HTML下拉菜单's重定向(使用JS)不适用于移动设备,但在PC上运行良好
- jQuery.getScript无法在移动设备上运行
- 如何将用户从jquery移动窗体键入的查询SQL发布到WCF服务,并在WCF服务上运行该查询
- 屏幕关闭时运行的移动Web应用程序
- 代码将不会运行.clearInterval在正方形中移动标题
- JqueryMobile布局是否同时在Web和移动设备上运行
- 有没有办法将Google Analytics for Web置于“试运行”模式,例如GA移动SDK
- 如何让javascript在桌面上运行函数,而不是在移动设备上运行函数
- 如何在移动视图中运行 jumpTo(n) 滑块猫头鹰-carusel.
- 如何得到这个:“如果移动不要在shopify上运行这个javascript(purechat)”
- 从移动浏览器中运行中排除代码
- 华丽弹出窗口无法在移动设备上运行
- 响应式导航在移动设备上未按预期运行
- jQuery mobile在移动到下一个页面后停止运行当前页面中使用的脚本
- 如何制作一个在移动设备上运行良好的动画手风琴?纯JS或WebKit transform3d
- 画廊无法在iPad/移动设备上运行
- 如何让JS代码在最小化或睡眠时在移动设备上运行