拖动在InternetExplorer中不起作用
dragging not working in internet explorer
我正在尝试调整大小,并在我的代码中拖动一个div。代码如下,但我在ie中根本无法拖动div,但我可以在chrome中拖动。但调整大小对两者都有效。请检查并指导我如何在例如中进行拖动
interact('.divname')
.resizable(true)
.on('resizemove', function (event) {
var target = event.target;
// add the change in coords to the previous width of the target element
var
newWidth = parseFloat(target.style.width ) + event.dx,
newHeight = parseFloat(target.style.height) + event.dy;
// update the element's style
target.style.width = newWidth + 'px';
target.style.height = newHeight + 'px';
//target.textContent = newWidth + '×' + newHeight;
});
interact('.divname')
.draggable({
// enable inertial throwing
inertia: true,
// keep the element within the area of it's parent
restrict: {
restriction: "parent",
endOnly: true,
elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
},
// call this function on every dragmove event
onmove: function (event) {
var target = event.target,
// keep the dragged position in the data-x/data-y attributes
x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
// translate the element
target.style.webkitTransform =
target.style.transform =
'translate(' + x + 'px, ' + y + 'px)';
// update the posiion attributes
target.setAttribute('data-x', x);
target.setAttribute('data-y', y);
},
// call this function on every dragend event
onend: function (event) {
var textEl = event.target.querySelector('p');
textEl && (textEl.textContent =
'moved a distance of '
+ (Math.sqrt(event.dx * event.dx +
event.dy * event.dy)|0) + 'px');
}
});
<div class="divname">
</div>
IE8不支持transform
,因此您的onmove
处理程序将无法在那里工作。此外,IE8中不支持textContent
,因此您的onend
处理程序将无法正常工作。
对于IE9,您可以进行转换,但需要使用类似于webkit
的供应商前缀ms
。
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 监视函数从服务返回不起作用,但作用域函数起作用
- 幻灯片滚动javascript不起作用
- 简单的javascript在Shopify中不起作用
- Recaptcha在IE7和IE8中不起作用
- Ember Data DS.Model's set函数不起作用
- JsFiddle上的鼠标事件不起作用
- 我的AngularJS表达式没有'不起作用
- 点击按钮输入不起作用
- 面向对象的Javascript代码在IE7中不起作用
- 分部隐藏在jquery中不起作用
- 在phonegap应用程序内部重定向不起作用
- Array.length似乎不起作用;console.log则显示其他情况
- $ionicplatform内的$scope不;不起作用
- 我的javascript for循环不起作用
- Meteor-添加用户自定义字段的方法不起作用
- 为什么 .focus() 不起作用,而 .css(“color”,“red”) 在同一个选择器上起作用
- Textarea必需的attribut在javascript中不起作用
- 为什么javascript:void(0)在Firefox中不起作用
- 退出全屏不起作用