Skip to content

Commit e44ca0f

Browse files
committed
publish build
1 parent e3e3d25 commit e44ca0f

File tree

22 files changed

+520
-389
lines changed

22 files changed

+520
-389
lines changed

lib/better-scroll/better-scroll.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/better-scroll/index.js

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
111111
"use strict";
112112
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
113113
/*!
114-
* better-normal-scroll v1.6.3
115-
* (c) 2016-2017 ustbhuangyi
114+
* better-normal-scroll v1.7.0
115+
* (c) 2016-2018 ustbhuangyi
116116
* Released under the MIT License.
117117
*/
118118
var slicedToArray = function () {
@@ -386,40 +386,36 @@ function tap(e, eventName) {
386386
}
387387

388388
function click(e) {
389-
var target = e.target;
390-
391-
if (!/(SELECT|INPUT|TEXTAREA)/i.test(target.tagName)) {
392-
var eventSource = void 0;
393-
if (e.type === 'mouseup' || e.type === 'mousecancel') {
394-
eventSource = e;
395-
} else if (e.type === 'touchend' || e.type === 'touchcancel') {
396-
eventSource = e.changedTouches[0];
397-
}
398-
var posSrc = {};
399-
if (eventSource) {
400-
posSrc.screenX = eventSource.screenX || 0;
401-
posSrc.screenY = eventSource.screenY || 0;
402-
posSrc.clientX = eventSource.clientX || 0;
403-
posSrc.clientY = eventSource.clientY || 0;
404-
}
405-
var ev = void 0;
406-
var event = 'click';
407-
var bubbles = true;
408-
// cancelable set to false in case of the conflict with fastclick
409-
var cancelable = false;
410-
if (typeof MouseEvent !== 'undefined') {
411-
ev = new MouseEvent(event, extend({
412-
bubbles: bubbles,
413-
cancelable: cancelable
414-
}, posSrc));
415-
} else {
416-
ev = document.createEvent('Event');
417-
ev.initEvent(event, bubbles, cancelable);
418-
extend(ev, posSrc);
419-
}
420-
ev._constructed = true;
421-
target.dispatchEvent(ev);
389+
var eventSource = void 0;
390+
if (e.type === 'mouseup' || e.type === 'mousecancel') {
391+
eventSource = e;
392+
} else if (e.type === 'touchend' || e.type === 'touchcancel') {
393+
eventSource = e.changedTouches[0];
394+
}
395+
var posSrc = {};
396+
if (eventSource) {
397+
posSrc.screenX = eventSource.screenX || 0;
398+
posSrc.screenY = eventSource.screenY || 0;
399+
posSrc.clientX = eventSource.clientX || 0;
400+
posSrc.clientY = eventSource.clientY || 0;
401+
}
402+
var ev = void 0;
403+
var event = 'click';
404+
var bubbles = true;
405+
// cancelable set to false in case of the conflict with fastclick
406+
var cancelable = false;
407+
if (typeof MouseEvent !== 'undefined') {
408+
ev = new MouseEvent(event, extend({
409+
bubbles: bubbles,
410+
cancelable: cancelable
411+
}, posSrc));
412+
} else {
413+
ev = document.createEvent('Event');
414+
ev.initEvent(event, bubbles, cancelable);
415+
extend(ev, posSrc);
422416
}
417+
ev._constructed = true;
418+
e.target.dispatchEvent(ev);
423419
}
424420

425421
function prepend(el, target) {
@@ -471,6 +467,7 @@ var DEFAULT_OPTIONS = {
471467
disableMouse: hasTouch,
472468
disableTouch: !hasTouch,
473469
observeDOM: true,
470+
autoBlur: true,
474471
/**
475472
* for picker
476473
* wheel: {
@@ -490,6 +487,13 @@ var DEFAULT_OPTIONS = {
490487
* threshold: 0.1,
491488
* stepX: 100,
492489
* stepY: 100,
490+
* speed: 400,
491+
* easing: {
492+
* style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
493+
* fn: function (t) {
494+
* return t * (2 - t)
495+
* }
496+
* }
493497
* listenFlick: true
494498
* }
495499
*/
@@ -540,6 +544,10 @@ function initMixin(BScroll) {
540544
this._initDOMObserver();
541545
}
542546

547+
if (this.options.autoBlur) {
548+
this._handleAutoBlur();
549+
}
550+
543551
this.refresh();
544552

545553
if (!this.options.snap) {
@@ -648,6 +656,15 @@ function initMixin(BScroll) {
648656
});
649657
};
650658

659+
BScroll.prototype._handleAutoBlur = function () {
660+
this.on('beforeScrollStart', function () {
661+
var activeElement = document.activeElement;
662+
if (activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA')) {
663+
activeElement.blur();
664+
}
665+
});
666+
};
667+
651668
BScroll.prototype._initDOMObserver = function () {
652669
var _this = this;
653670

@@ -1157,7 +1174,7 @@ function coreMixin(BScroll) {
11571174

11581175
this.directionX = 0;
11591176
this.directionY = 0;
1160-
easing = ease.bounce;
1177+
easing = this.options.snap.easing || ease.bounce;
11611178
}
11621179

11631180
if (newX !== this.x || newY !== this.y) {
@@ -1199,7 +1216,7 @@ function coreMixin(BScroll) {
11991216
tap(e, this.options.tap);
12001217
}
12011218

1202-
if (this.options.click) {
1219+
if (this.options.click && !preventDefaultException(e.target, this.options.preventDefaultException)) {
12031220
click(e);
12041221
}
12051222
return true;
@@ -1750,14 +1767,16 @@ function snapMixin(BScroll) {
17501767
BScroll.prototype._goToPage = function (x) {
17511768
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
17521769
var time = arguments[2];
1753-
var easing = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ease.bounce;
1770+
var easing = arguments[3];
17541771

17551772
var snap = this.options.snap;
17561773

17571774
if (!snap || !this.pages) {
17581775
return;
17591776
}
17601777

1778+
easing = easing || snap.easing || ease.bounce;
1779+
17611780
if (x >= this.pages.length) {
17621781
x = this.pages.length - 1;
17631782
} else if (x < 0) {
@@ -2167,8 +2186,8 @@ function pullUpMixin(BScroll) {
21672186

21682187
function checkToEnd(pos) {
21692188
if (this.movingDirectionY === DIRECTION_UP && pos.y <= this.maxScrollY + threshold) {
2170-
this.trigger('pullingUp');
21712189
this.pullupWatching = false;
2190+
this.trigger('pullingUp');
21722191
this.off('scroll', checkToEnd);
21732192
}
21742193
}
@@ -2211,7 +2230,7 @@ scrollbarMixin(BScroll);
22112230
pullDownMixin(BScroll);
22122231
pullUpMixin(BScroll);
22132232

2214-
BScroll.Version = '1.6.3';
2233+
BScroll.Version = '1.7.0';
22152234

22162235
/* harmony default export */ __webpack_exports__["default"] = (BScroll);
22172236

0 commit comments

Comments
 (0)