Skip to content

Commit 31534f7

Browse files
committed
[build] 0.5.4
1 parent b9d67a7 commit 31534f7

File tree

9 files changed

+151
-66
lines changed

9 files changed

+151
-66
lines changed

bundle-size/common.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

bundle-size/es.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

bundle-size/min.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

bundle-size/umd.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/index.browser.js

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/**
3-
* chimee v0.5.3
3+
* chimee v0.5.4
44
* (c) 2017 toxic-johann
55
* Released under MIT
66
*/
@@ -4127,7 +4127,7 @@ var CustEvent = function () {
41274127
}();
41284128

41294129
/**
4130-
* chimee-helper-dom v0.1.4
4130+
* chimee-helper-dom v0.1.7
41314131
* (c) 2017 huzunjie
41324132
* Released under MIT
41334133
*/
@@ -4494,6 +4494,20 @@ function hasClassName(el, className) {
44944494
return new RegExp('(?:^|\\s)' + className + '(?=\\s|$)').test(el.className);
44954495
}
44964496

4497+
/**
4498+
* addEventListener 是否已支持 passive
4499+
* @return {Boolean}
4500+
*/
4501+
var supportsPassive = false;
4502+
try {
4503+
var opts = Object.defineProperty({}, 'passive', {
4504+
get: function get() {
4505+
supportsPassive = true;
4506+
}
4507+
});
4508+
window.addEventListener('test', null, opts);
4509+
} catch (e) {}
4510+
44974511
/**
44984512
* 为HTML元素移除事件监听
44994513
* @param {HTMLElement} el 目标元素
@@ -4506,6 +4520,9 @@ function removeEvent(el, type, handler) {
45064520
var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
45074521
var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
45084522

4523+
if (capture !== undefined && !isBoolean(capture) && supportsPassive) {
4524+
capture = { passive: true };
4525+
}
45094526
if (once) {
45104527
/* 尝试从缓存中读取包装后的方法 */
45114528
var handlerWrap = removeEventCache$1(el, type + '_once', handler);
@@ -4528,6 +4545,9 @@ function addEvent(el, type, handler) {
45284545
var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
45294546
var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
45304547

4548+
if (capture !== undefined && !isBoolean(capture) && supportsPassive) {
4549+
capture = { passive: true };
4550+
}
45314551
if (once) {
45324552
var oldHandler = handler;
45334553
handler = function () {
@@ -4558,7 +4578,9 @@ function addEvent(el, type, handler) {
45584578
function addDelegate(el, selector, type, handler) {
45594579
var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
45604580

4561-
4581+
if (capture !== undefined && !isBoolean(capture) && supportsPassive) {
4582+
capture = { passive: true };
4583+
}
45624584
var handlerWrap = function handlerWrap(e) {
45634585
var targetElsArr = findParents(e.target || e.srcElement, el, true);
45644586
var targetElArr = query(selector, el, true);
@@ -4597,6 +4619,9 @@ function addDelegate(el, selector, type, handler) {
45974619
function removeDelegate(el, selector, type, handler) {
45984620
var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
45994621

4622+
if (capture !== undefined && !isBoolean(capture) && supportsPassive) {
4623+
capture = { passive: true };
4624+
}
46004625
/* 尝试从缓存中读取包装后的方法 */
46014626
var handlerWrap = removeEventCache$1(el, type + '_delegate_' + selector, handler);
46024627
handlerWrap && el.removeEventListener(type, handlerWrap, capture);
@@ -5061,7 +5086,7 @@ var NodeWrap = function () {
50615086
}();
50625087

50635088
/**
5064-
* chimee-helper v0.2.6
5089+
* chimee-helper v0.2.8
50655090
* (c) 2017 toxic-johann
50665091
* Released under MIT
50675092
*/
@@ -5851,7 +5876,8 @@ var _Map = unwrapExports(map);
58515876

58525877
var videoEvents = ['abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied', 'encrypted', 'ended', 'error', 'interruptbegin', 'interruptend', 'loadeddata', 'loadedmetadata', 'loadstart', 'mozaudioavailable', 'pause', 'play', 'playing', 'progress', 'ratechange', 'seeked', 'seeking', 'stalled', 'suspend', 'timeupdate', 'volumechange', 'waiting'];
58535878
var videoReadOnlyProperties = ['buffered', 'currentSrc', 'duration', 'error', 'ended', 'networkState', 'paused', 'readyState', 'seekable', 'sinkId', 'controlsList', 'tabIndex', 'dataset', 'offsetHeight', 'offsetLeft', 'offsetParent', 'offsetTop', 'offsetWidth'];
5854-
var domEvents = ['beforeinput', 'blur', 'click', 'compositionend', 'compositionstart', 'compositionupdate', 'dblclick', 'focus', 'focusin', 'focusout', 'input', 'keydown', 'keypress', 'keyup', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'resize', 'scroll', 'select', 'wheel', 'fullscreenchange', 'contextmenu', 'touchstart', 'touchmove', 'touchend'];
5879+
var domEvents = ['beforeinput', 'blur', 'click', 'compositionend', 'compositionstart', 'compositionupdate', 'dblclick', 'focus', 'focusin', 'focusout', 'input', 'keydown', 'keypress', 'keyup', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'resize', 'scroll', 'select', 'wheel', 'mousewheel', 'fullscreenchange', 'contextmenu', 'touchstart', 'touchmove', 'touchend'];
5880+
var passiveEvents = ['wheel', 'mousewheel', 'touchstart', 'touchmove'];
58555881
var selfProcessorEvents = ['silentLoad', 'fullscreen'];
58565882
var kernelMethods = ['play', 'pause', 'seek'];
58575883
var dispatcherMethods = ['load'];
@@ -8825,7 +8851,7 @@ var Plugin = (_dec$3 = autobindClass(), _dec$3(_class$3 = function (_VideoWrappe
88258851
var _this = _possibleConstructorReturn(this, (Plugin.__proto__ || _Object$getPrototypeOf(Plugin)).call(this));
88268852

88278853
_this.destroyed = false;
8828-
_this.VERSION = '0.5.3';
8854+
_this.VERSION = '0.5.4';
88298855
_this.__operable = true;
88308856
_this.__level = 0;
88318857

@@ -9453,8 +9479,8 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
94539479
* referrence of video's dom element
94549480
*/
94559481
this.installVideo(videoElement);
9456-
domEvents.forEach(function (key) {
9457-
var cfn = function cfn() {
9482+
this._addDomEvents(this.container, this.containerDomEventHandlerList, function (key) {
9483+
return function () {
94589484
var _dispatcher$bus;
94599485

94609486
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
@@ -9463,9 +9489,9 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
94639489

94649490
return (_dispatcher$bus = _this.__dispatcher.bus).triggerSync.apply(_dispatcher$bus, ['c_' + key].concat(_toConsumableArray(args)));
94659491
};
9466-
_this.containerDomEventHandlerList.push(cfn);
9467-
addEvent(_this.container, key, cfn);
9468-
var wfn = function wfn() {
9492+
});
9493+
this._addDomEvents(this.wrapper, this.wrapperDomEventHandlerList, function (key) {
9494+
return function () {
94699495
var _dispatcher$bus2;
94709496

94719497
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
@@ -9474,8 +9500,6 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
94749500

94759501
return (_dispatcher$bus2 = _this.__dispatcher.bus).triggerSync.apply(_dispatcher$bus2, ['w_' + key].concat(_toConsumableArray(args)));
94769502
};
9477-
_this.wrapperDomEventHandlerList.push(wfn);
9478-
addEvent(_this.wrapper, key, wfn);
94799503
});
94809504
this._fullscreenMonitor();
94819505
index.on('fullscreenchange', this._fullscreenMonitor);
@@ -9544,10 +9568,8 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
95449568
_this2.videoEventHandlerList.push(fn);
95459569
addEvent(videoElement, key, fn);
95469570
});
9547-
domEvents.forEach(function (key) {
9548-
var fn = _this2._getEventHandler(key, { penetrate: true });
9549-
_this2.videoDomEventHandlerList.push(fn);
9550-
addEvent(videoElement, key, fn);
9571+
this._addDomEvents(videoElement, this.videoDomEventHandlerList, function (key) {
9572+
return _this2._getEventHandler(key, { penetrate: true });
95519573
});
95529574
this.videoElement = videoElement;
95539575
return videoElement;
@@ -9571,6 +9593,7 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
95719593
delete this.videoElement;
95729594
return videoElement;
95739595
}
9596+
95749597
/**
95759598
* each plugin has its own dom node, this function will create one or them.
95769599
* we support multiple kind of el
@@ -9626,10 +9649,8 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
96269649
// auto forward the event if this plugin can be penetrate
96279650
if (penetrate) {
96289651
this.__domEventHandlerList[id] = this.__domEventHandlerList[id] || [];
9629-
domEvents.forEach(function (key) {
9630-
var fn = _this4._getEventHandler(key, { penetrate: penetrate });
9631-
addEvent(node, key, fn);
9632-
_this4.__domEventHandlerList[id].push(fn);
9652+
this._addDomEvents(node, this.__domEventHandlerList[id], function (key) {
9653+
return _this4._getEventHandler(key, { penetrate: penetrate });
96339654
});
96349655
this.__videoExtendedNodes.push(node);
96359656
}
@@ -9640,6 +9661,7 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
96409661
outerElement.insertBefore(node, originElement.nextSibling);
96419662
return node;
96429663
}
9664+
96439665
/**
96449666
* remove plugin's dom
96459667
*/
@@ -9663,6 +9685,7 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
96639685
}
96649686
delete this.plugins[id];
96659687
}
9688+
96669689
/**
96679690
* Set zIndex for a plugins list
96689691
*/
@@ -9677,6 +9700,7 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
96779700
return setStyle(key.match(/^(videoElement|container)$/) ? _this6[key] : _this6.plugins[key], 'z-index', ++index$$1);
96789701
});
96799702
}
9703+
96809704
/**
96819705
* set attribute on our dom
96829706
* @param {string} attr attribute's name
@@ -9736,6 +9760,7 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
97369760
value: function focus() {
97379761
this.videoElement.focus();
97389762
}
9763+
97399764
/**
97409765
* function called when we distory
97419766
*/
@@ -9755,6 +9780,25 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
97559780
delete this.wrapper;
97569781
delete this.plugins;
97579782
}
9783+
9784+
/**
9785+
* bind all dom events on one element
9786+
* we will use passive mode if it support
9787+
*/
9788+
9789+
}, {
9790+
key: '_addDomEvents',
9791+
value: function _addDomEvents(element, handlerList, handlerGenerate) {
9792+
domEvents.forEach(function (key) {
9793+
var fn = handlerGenerate(key);
9794+
handlerList.push(fn);
9795+
if (passiveEvents.indexOf(key) > -1) {
9796+
addEvent(element, key, fn, false, { passive: true });
9797+
return;
9798+
}
9799+
addEvent(element, key, fn);
9800+
});
9801+
}
97589802
}, {
97599803
key: '_autoFocusToVideo',
97609804
value: function _autoFocusToVideo(element) {
@@ -9787,6 +9831,7 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
97879831
this.__dispatcher.bus.triggerSync('fullscreenchange', evt);
97889832
}
97899833
}
9834+
97909835
/**
97919836
* get the event handler for dom to bind
97929837
*/
@@ -10745,7 +10790,7 @@ var Chimee = (_dec = autobindClass(), _dec(_class = (_class2 = (_temp = _class3
1074510790
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'version', [frozen], {
1074610791
enumerable: true,
1074710792
initializer: function initializer() {
10748-
return '0.5.3';
10793+
return '0.5.4';
1074910794
}
1075010795
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'config', [frozen], {
1075110796
enumerable: true,

0 commit comments

Comments
 (0)