Skip to content

Commit 0a8ea33

Browse files
committed
readme modifed, gulpfile
1 parent 661c8bb commit 0a8ea33

21 files changed

+420
-151
lines changed

README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,21 @@ To learn more advanced features, please refer to [WIKI](https://github.com/BE-FE
331331
- Default: 0
332332

333333

334+
##### fingerRecognitionRange
335+
336+
- `{Number}`
337+
- 误触识别范围,大于范围值的touchMove被视为有效滑动距离
338+
- 默认:10(px)
339+
340+
334341
##### fixPage
335342

336343
- `{Boolean}`
337344
- Native event stop
338345
- In the original scene shield trigger event, such as: scroll, drag, zoom, etc.
339346
    - "A" elements to prevent the mobile terminal is recommended to use tap (touch-based event jointly judgment) custom
340347
    - Of the form element "SELECT", "INPUT", "TEXTAREA", "BUTTON", "LABEL", under any circumstances be blocked
348+
- *排除策略:若参数类型为字符串(规则,querySelector选择器字符串)或数组(多个规则),此选项为开启状态(true)并排除复合规则的元素,与`iSlider.FIX_PAGE_TAGS`相同对待
341349
- Default: true (Enabled)
342350

343351

@@ -488,7 +496,48 @@ S.on('slideChanged', callBack);
488496
- Parameters: None
489497

490498

491-
### Static methods
499+
### 常量
500+
501+
#### VERSION
502+
503+
- `{String}`
504+
- 版本号
505+
506+
#### EVENTS
507+
508+
- `{Array}`
509+
- 事件回调列表
510+
511+
#### EASING
512+
513+
- `{Array}`
514+
- 动画效果(easing)规则列表
515+
- 0: `{Array}` `['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out']`
516+
- 1: `{Regexp}` 贝塞尔曲线公式,同CSS3中的写法
517+
518+
#### FIX_PAGE_TAGS
519+
520+
- `{Array}`
521+
- 对应fixPage的表单元素白名单
522+
523+
#### NODE_TYPE
524+
525+
- `{Array}`
526+
- 场景类型
527+
528+
#### TRANSITION_END_EVENT
529+
530+
- `{String}`
531+
- 动画效果结束事件名
532+
533+
#### DEVICE_EVENTS
534+
535+
- `{Object}`
536+
- `{{hasTouch, startEvt, moveEvt, endEvt, cancelEvt, resizeEvt}}`
537+
- 根据设备所匹配的事件
538+
539+
540+
### 静态方法
492541

493542
#### extend
494543

@@ -611,6 +660,7 @@ S.on('slideChanged', callBack);
611660
- Same with the static method "regPlugin"
612661
- ** This method will register the plug to iSlider instance, registered at the same time are automatically added to the list of active plug-ins, and automatically performs initialization.**
613662

663+
614664
#### loadData
615665

616666
- Loading new Datasheets

README_Chinese.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,21 @@ var data = [{
331331
- 默认:0
332332

333333

334+
##### fingerRecognitionRange
335+
336+
- `{Number}`
337+
- 误触识别范围,大于范围值的touchMove被视为有效滑动距离
338+
- 默认:10(px)
339+
340+
334341
##### fixPage
335342

336-
- `{Boolean}`
343+
- `{Boolean|Array|String}`
337344
- 原生事件阻止
338345
- 场景内屏蔽原生事件的触发,如:滚动、拖拽、缩放等
339346
- "A"元素,阻止,移动端建议使用自定义的tap(touch系事件联合判断)
340347
- 对表单类元素"SELECT"、"INPUT"、"TEXTAREA"、"BUTTON"、"LABEL",任何情况下均不进行阻止
348+
- *排除策略:若参数类型为字符串(规则,querySelector选择器字符串)或数组(多个规则),此选项为开启状态(true)并排除复合规则的元素,与`iSlider.FIX_PAGE_TAGS`相同对待
341349
- 默认:true(开启)
342350

343351

@@ -488,6 +496,47 @@ S.on('slideChanged', callBack);
488496
- 参数:无
489497

490498

499+
### 常量
500+
501+
#### VERSION
502+
503+
- `{String}`
504+
- 版本号
505+
506+
#### EVENTS
507+
508+
- `{Array}`
509+
- 事件回调列表
510+
511+
#### EASING
512+
513+
- `{Array}`
514+
- 动画效果(easing)规则列表
515+
- 0: `{Array}` `['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out']`
516+
- 1: `{Regexp}` 贝塞尔曲线公式,同CSS3中的写法
517+
518+
#### FIX_PAGE_TAGS
519+
520+
- `{Array}`
521+
- 对应fixPage的表单元素白名单
522+
523+
#### NODE_TYPE
524+
525+
- `{Array}`
526+
- 场景类型
527+
528+
#### TRANSITION_END_EVENT
529+
530+
- `{String}`
531+
- 动画效果结束事件名
532+
533+
#### DEVICE_EVENTS
534+
535+
- `{Object}`
536+
- `{{hasTouch, startEvt, moveEvt, endEvt, cancelEvt, resizeEvt}}`
537+
- 根据设备所匹配的事件
538+
539+
491540
### 静态方法
492541

493542
#### extend

bower.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"thumbnails",
3939
"karma.conf.js",
4040
"gulpfile.js",
41-
"index.html"
41+
"index.html",
42+
"gulp"
4243
],
43-
"version": "2.1.3"
44+
"version": "2.1.4"
4445
}

build/iSlider.js

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,28 @@
9898
return Array.prototype.slice.apply(a, Array.prototype.slice.call(arguments, 1));
9999
}
100100

101+
/**
102+
* Whether this node in rule
103+
*
104+
* @param {HTMLElement} target
105+
* @param {Array} rule
106+
* @returns {boolean}
107+
*/
108+
function isItself(target, rule) {
109+
if (isArray(rule)) {
110+
var parent = target.parentNode;
111+
for (var i = 0; i < rule.length; i++) {
112+
try {
113+
if (parent.querySelector(rule[i]) === target) {
114+
return true;
115+
}
116+
} catch (e) {
117+
}
118+
}
119+
}
120+
return false;
121+
}
122+
101123
/**
102124
* @constructor
103125
*
@@ -161,7 +183,7 @@
161183
* version
162184
* @type {string}
163185
*/
164-
iSlider.VERSION = '2.1.3';
186+
iSlider.VERSION = '2.1.4';
165187

166188
/**
167189
* Event white list
@@ -240,6 +262,22 @@
240262
return null;
241263
})();
242264

265+
/**
266+
* Event match depending on the browser supported
267+
* @type {{hasTouch, startEvt, moveEvt, endEvt, cancelEvt, resizeEvt}}
268+
*/
269+
iSlider.DEVICE_EVENTS = (function () {
270+
var hasTouch = !!(('ontouchstart' in global) || global.DocumentTouch && document instanceof global.DocumentTouch);
271+
return {
272+
hasTouch: hasTouch,
273+
startEvt: hasTouch ? 'touchstart' : 'mousedown',
274+
moveEvt: hasTouch ? 'touchmove' : 'mousemove',
275+
endEvt: hasTouch ? 'touchend' : 'mouseup',
276+
cancelEvt: hasTouch ? 'touchcancel' : 'mouseout',
277+
resizeEvt: 'onorientationchange' in global ? 'orientationchange' : 'resize'
278+
};
279+
})();
280+
243281
/**
244282
* Extend
245283
* @public
@@ -267,18 +305,6 @@
267305
}
268306
};
269307

270-
iSlider.deviceEvents = (function () {
271-
var hasTouch = !!(('ontouchstart' in global) || global.DocumentTouch && document instanceof global.DocumentTouch);
272-
return {
273-
hasTouch: hasTouch,
274-
startEvt: hasTouch ? 'touchstart' : 'mousedown',
275-
moveEvt: hasTouch ? 'touchmove' : 'mousemove',
276-
endEvt: hasTouch ? 'touchend' : 'mouseup',
277-
cancelEvt: hasTouch ? 'touchcancel' : 'mouseout',
278-
resizeEvt: 'onorientationchange' in global ? 'orientationchange' : 'resize'
279-
};
280-
})();
281-
282308
/**
283309
* Plugins
284310
* @type {{}}
@@ -477,7 +503,16 @@
477503
* @type {Boolean}
478504
* @public
479505
*/
480-
self.fixPage = opts.fixPage == null ? true : !!opts.fixPage;
506+
self.fixPage = (function () {
507+
var fp = opts.fixPage;
508+
if (fp === false || fp === 0) {
509+
return false;
510+
}
511+
if (isArray(fp) && fp.length > 0 || typeof fp === 'string' && fp !== '') {
512+
return [].concat(fp);
513+
}
514+
return true;
515+
})();
481516

482517
/**
483518
* Fill seam when render
@@ -665,7 +700,7 @@
665700
* @type {{hasTouch, startEvt, moveEvt, endEvt}}
666701
* @private
667702
*/
668-
self.deviceEvents = iSlider.deviceEvents;
703+
self.deviceEvents = iSlider.DEVICE_EVENTS;
669704

670705
/**
671706
* Finger recognition range, prevent inadvertently touch
@@ -1107,7 +1142,7 @@
11071142
*/
11081143
iSliderPrototype.startHandler = function (evt) {
11091144
if (this.fixPage) {
1110-
if (iSlider.FIX_PAGE_TAGS.indexOf(evt.target.tagName) < 0) {
1145+
if (iSlider.FIX_PAGE_TAGS.indexOf(evt.target.tagName.toUpperCase()) < 0 && !isItself(evt.target, this.fixPage)) {
11111146
evt.preventDefault();
11121147
}
11131148
}

build/iSlider.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/public/js/iSlider.js

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,28 @@
9898
return Array.prototype.slice.apply(a, Array.prototype.slice.call(arguments, 1));
9999
}
100100

101+
/**
102+
* Whether this node in rule
103+
*
104+
* @param {HTMLElement} target
105+
* @param {Array} rule
106+
* @returns {boolean}
107+
*/
108+
function isItself(target, rule) {
109+
if (isArray(rule)) {
110+
var parent = target.parentNode;
111+
for (var i = 0; i < rule.length; i++) {
112+
try {
113+
if (parent.querySelector(rule[i]) === target) {
114+
return true;
115+
}
116+
} catch (e) {
117+
}
118+
}
119+
}
120+
return false;
121+
}
122+
101123
/**
102124
* @constructor
103125
*
@@ -161,7 +183,7 @@
161183
* version
162184
* @type {string}
163185
*/
164-
iSlider.VERSION = '2.1.3';
186+
iSlider.VERSION = '2.1.4';
165187

166188
/**
167189
* Event white list
@@ -240,6 +262,22 @@
240262
return null;
241263
})();
242264

265+
/**
266+
* Event match depending on the browser supported
267+
* @type {{hasTouch, startEvt, moveEvt, endEvt, cancelEvt, resizeEvt}}
268+
*/
269+
iSlider.DEVICE_EVENTS = (function () {
270+
var hasTouch = !!(('ontouchstart' in global) || global.DocumentTouch && document instanceof global.DocumentTouch);
271+
return {
272+
hasTouch: hasTouch,
273+
startEvt: hasTouch ? 'touchstart' : 'mousedown',
274+
moveEvt: hasTouch ? 'touchmove' : 'mousemove',
275+
endEvt: hasTouch ? 'touchend' : 'mouseup',
276+
cancelEvt: hasTouch ? 'touchcancel' : 'mouseout',
277+
resizeEvt: 'onorientationchange' in global ? 'orientationchange' : 'resize'
278+
};
279+
})();
280+
243281
/**
244282
* Extend
245283
* @public
@@ -267,18 +305,6 @@
267305
}
268306
};
269307

270-
iSlider.deviceEvents = (function () {
271-
var hasTouch = !!(('ontouchstart' in global) || global.DocumentTouch && document instanceof global.DocumentTouch);
272-
return {
273-
hasTouch: hasTouch,
274-
startEvt: hasTouch ? 'touchstart' : 'mousedown',
275-
moveEvt: hasTouch ? 'touchmove' : 'mousemove',
276-
endEvt: hasTouch ? 'touchend' : 'mouseup',
277-
cancelEvt: hasTouch ? 'touchcancel' : 'mouseout',
278-
resizeEvt: 'onorientationchange' in global ? 'orientationchange' : 'resize'
279-
};
280-
})();
281-
282308
/**
283309
* Plugins
284310
* @type {{}}
@@ -477,7 +503,16 @@
477503
* @type {Boolean}
478504
* @public
479505
*/
480-
self.fixPage = opts.fixPage == null ? true : !!opts.fixPage;
506+
self.fixPage = (function () {
507+
var fp = opts.fixPage;
508+
if (fp === false || fp === 0) {
509+
return false;
510+
}
511+
if (isArray(fp) && fp.length > 0 || typeof fp === 'string' && fp !== '') {
512+
return [].concat(fp);
513+
}
514+
return true;
515+
})();
481516

482517
/**
483518
* Fill seam when render
@@ -665,7 +700,7 @@
665700
* @type {{hasTouch, startEvt, moveEvt, endEvt}}
666701
* @private
667702
*/
668-
self.deviceEvents = iSlider.deviceEvents;
703+
self.deviceEvents = iSlider.DEVICE_EVENTS;
669704

670705
/**
671706
* Finger recognition range, prevent inadvertently touch
@@ -1107,7 +1142,7 @@
11071142
*/
11081143
iSliderPrototype.startHandler = function (evt) {
11091144
if (this.fixPage) {
1110-
if (iSlider.FIX_PAGE_TAGS.indexOf(evt.target.tagName) < 0) {
1145+
if (iSlider.FIX_PAGE_TAGS.indexOf(evt.target.tagName.toUpperCase()) < 0 && !isItself(evt.target, this.fixPage)) {
11111146
evt.preventDefault();
11121147
}
11131148
}

0 commit comments

Comments
 (0)