【发布时间】:2011-09-15 12:12:24
【问题描述】:
我对 jquery ui 非常陌生,但由于我的项目的性质,我有点陷入了困境!基本上我需要帮助的是我有一个文件,该文件将某些自定义项应用于 jquery ui 可拖动小部件,并且我想进一步自定义以启用触摸功能,以便该小部件在移动触摸屏设备上运行。也就是说,我的代码看起来像这样:
/*
* jQuery UI Draggable
*
* Depends:
* jquery.ui.core.js
* jquery.ui.mouse.js
* jquery.ui.widget.js
*/
(function( $, undefined ) {
$.widget("ui.draggable", $.ui.mouse, {
widgetEventPrefix: "drag",
options: {
addClasses: true,
appendTo: "parent",
axis: false,
connectToSortable: false,
containment: false,
cursor: "auto",
cursorAt: false,
grid: false,
handle: false,
helper: "original",
iframeFix: false,
opacity: false,
refreshPositions: false,
revert: false,
revertDuration: 500,
scope: "default",
scroll: true,
scrollSensitivity: 20,
scrollSpeed: 20,
snap: false,
snapMode: "both",
snapTolerance: 20,
stack: false,
zIndex: false
},
_create: function() {
if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
this.element[0].style.position = 'relative';
(this.options.addClasses && this.element.addClass("ui-draggable"));
(this.options.disabled && this.element.addClass("ui-draggable-disabled"));
this._mouseInit();
},
destroy: function() {
if(!this.element.data('draggable')) return;
this.element
.removeData("draggable")
.unbind(".draggable")
.removeClass("ui-draggable"
+ " ui-draggable-dragging"
+ " ui-draggable-disabled");
this._mouseDestroy();
return this;
},
...等等。
我看过这篇文章:How can I make a jQuery UI 'draggable()' div draggable for touchscreen?,它看起来是我正在尝试做的事情的理想解决方案,但我不确定“将其链接到我的 jQuery UI draggable() 是什么意思称呼 ”。在我的代码中应该在哪里阻止:
.touch({
animate: false,
sticky: false,
dragx: true,
dragy: true,
rotate: false,
resort: true,
scale: false
});
去吗?这可能是一个愚蠢的问题,对不起。我是初学者! :) 谢谢!!
【问题讨论】:
标签: jquery user-interface touch jqtouch jquery-ui-draggable