修复了一些问题
This commit is contained in:
1 parent
c484ee6ef3
commit
e877ceb560
28 files changed
+565
-535
No files matched your search
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
$.fn.minitouch = function (options) {
|
||||
jQuery.fn.minitouch = function (options) {
|
||||
// 合并默认选项和用户提供的选项
|
||||
options = $.extend({
|
||||
options = jQuery.extend({
|
||||
direction: 'bottom',
|
||||
selector: '',
|
||||
start_selector: '',
|
||||
@@ -13,7 +13,7 @@ $.fn.minitouch = function (options) {
|
||||
inEnd: false,
|
||||
}, options);
|
||||
|
||||
var $element = $(this); // 当前元素
|
||||
var $element = jQuery(this); // 当前元素
|
||||
var isStop = false; // 是否停止拖动
|
||||
var threshold = options.depreciation; // 拖动阈值
|
||||
var initialX = 0, initialY = 0; // 初始触摸坐标
|
||||
@@ -60,7 +60,7 @@ $.fn.minitouch = function (options) {
|
||||
isDragging = true;
|
||||
|
||||
// 兼容swiper
|
||||
if ($(event.target).parentsUntil(touchSelector, '.swiper-container,.scroll-x').length) {
|
||||
if (jQuery(event.target).parentsUntil(touchSelector, '.swiper-container,.scroll-x').length) {
|
||||
isDragging = false;
|
||||
}
|
||||
})
|
||||
@@ -68,9 +68,9 @@ $.fn.minitouch = function (options) {
|
||||
.on("touchmove pointermove MSPointerMove", touchSelector, function (event) {
|
||||
var $moveElement = options.start_selector ?
|
||||
(options.selector ? $element.find(options.selector) : $element.find(options.start_selector)) :
|
||||
$(this);
|
||||
jQuery(this);
|
||||
|
||||
if ($.isFunction(options.stop)) {
|
||||
if (jQuery.isFunction(options.stop)) {
|
||||
isStop = options.stop($element, $moveElement, initialX, initialY);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ $.fn.minitouch = function (options) {
|
||||
if (deltaX !== 0 || deltaY !== 0) {
|
||||
event.preventDefault ? event.preventDefault() : event.returnValue = false;
|
||||
applyCssTransition($moveElement, deltaX, deltaY, isDragging, 'grab');
|
||||
$.isFunction(options.onIng) && options.onIng($element, $moveElement, deltaX, deltaY);
|
||||
jQuery.isFunction(options.onIng) && options.onIng($element, $moveElement, deltaX, deltaY);
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -107,16 +107,16 @@ $.fn.minitouch = function (options) {
|
||||
.on('touchend touchcancel pointerup MSPointerUp', touchSelector, function () {
|
||||
var $moveElement = options.start_selector ?
|
||||
(options.selector ? $element.find(options.selector) : $element.find(options.start_selector)) :
|
||||
$(this);
|
||||
jQuery(this);
|
||||
|
||||
if (isDragging && !isStop) {
|
||||
applyCssTransition($moveElement, 0, 0, "null", '');
|
||||
$.isFunction(options.inEnd) && options.inEnd($element, $moveElement, deltaX, deltaY);
|
||||
jQuery.isFunction(options.inEnd) && options.inEnd($element, $moveElement, deltaX, deltaY);
|
||||
if (Math.abs(deltaX) > threshold || Math.abs(deltaY) > threshold) {
|
||||
$.isFunction(options.onEnd) && options.onEnd($element, $moveElement, deltaX, deltaY);
|
||||
jQuery.isFunction(options.onEnd) && options.onEnd($element, $moveElement, deltaX, deltaY);
|
||||
}
|
||||
initialX = initialY = finalX = finalY = angle = deltaX = deltaY = 0;
|
||||
isDragging = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user