Skip to content

Commit

Permalink
[build] 0.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
toxic-johann committed Nov 25, 2017
1 parent b9d67a7 commit 31534f7
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 66 deletions.
2 changes: 1 addition & 1 deletion bundle-size/common.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle-size/es.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle-size/min.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle-size/umd.html

Large diffs are not rendered by default.

89 changes: 67 additions & 22 deletions lib/index.browser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/**
* chimee v0.5.3
* chimee v0.5.4
* (c) 2017 toxic-johann
* Released under MIT
*/
Expand Down Expand Up @@ -4127,7 +4127,7 @@ var CustEvent = function () {
}();

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

/**
* addEventListener 是否已支持 passive
* @return {Boolean}
*/
var supportsPassive = false;
try {
var opts = Object.defineProperty({}, 'passive', {
get: function get() {
supportsPassive = true;
}
});
window.addEventListener('test', null, opts);
} catch (e) {}

/**
* 为HTML元素移除事件监听
* @param {HTMLElement} el 目标元素
Expand All @@ -4506,6 +4520,9 @@ function removeEvent(el, type, handler) {
var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;

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

if (capture !== undefined && !isBoolean(capture) && supportsPassive) {
capture = { passive: true };
}
if (once) {
var oldHandler = handler;
handler = function () {
Expand Down Expand Up @@ -4558,7 +4578,9 @@ function addEvent(el, type, handler) {
function addDelegate(el, selector, type, handler) {
var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;


if (capture !== undefined && !isBoolean(capture) && supportsPassive) {
capture = { passive: true };
}
var handlerWrap = function handlerWrap(e) {
var targetElsArr = findParents(e.target || e.srcElement, el, true);
var targetElArr = query(selector, el, true);
Expand Down Expand Up @@ -4597,6 +4619,9 @@ function addDelegate(el, selector, type, handler) {
function removeDelegate(el, selector, type, handler) {
var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;

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

/**
* chimee-helper v0.2.6
* chimee-helper v0.2.8
* (c) 2017 toxic-johann
* Released under MIT
*/
Expand Down Expand Up @@ -5851,7 +5876,8 @@ var _Map = unwrapExports(map);

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'];
var videoReadOnlyProperties = ['buffered', 'currentSrc', 'duration', 'error', 'ended', 'networkState', 'paused', 'readyState', 'seekable', 'sinkId', 'controlsList', 'tabIndex', 'dataset', 'offsetHeight', 'offsetLeft', 'offsetParent', 'offsetTop', 'offsetWidth'];
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'];
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'];
var passiveEvents = ['wheel', 'mousewheel', 'touchstart', 'touchmove'];
var selfProcessorEvents = ['silentLoad', 'fullscreen'];
var kernelMethods = ['play', 'pause', 'seek'];
var dispatcherMethods = ['load'];
Expand Down Expand Up @@ -8825,7 +8851,7 @@ var Plugin = (_dec$3 = autobindClass(), _dec$3(_class$3 = function (_VideoWrappe
var _this = _possibleConstructorReturn(this, (Plugin.__proto__ || _Object$getPrototypeOf(Plugin)).call(this));

_this.destroyed = false;
_this.VERSION = '0.5.3';
_this.VERSION = '0.5.4';
_this.__operable = true;
_this.__level = 0;

Expand Down Expand Up @@ -9453,8 +9479,8 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
* referrence of video's dom element
*/
this.installVideo(videoElement);
domEvents.forEach(function (key) {
var cfn = function cfn() {
this._addDomEvents(this.container, this.containerDomEventHandlerList, function (key) {
return function () {
var _dispatcher$bus;

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

return (_dispatcher$bus = _this.__dispatcher.bus).triggerSync.apply(_dispatcher$bus, ['c_' + key].concat(_toConsumableArray(args)));
};
_this.containerDomEventHandlerList.push(cfn);
addEvent(_this.container, key, cfn);
var wfn = function wfn() {
});
this._addDomEvents(this.wrapper, this.wrapperDomEventHandlerList, function (key) {
return function () {
var _dispatcher$bus2;

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

return (_dispatcher$bus2 = _this.__dispatcher.bus).triggerSync.apply(_dispatcher$bus2, ['w_' + key].concat(_toConsumableArray(args)));
};
_this.wrapperDomEventHandlerList.push(wfn);
addEvent(_this.wrapper, key, wfn);
});
this._fullscreenMonitor();
index.on('fullscreenchange', this._fullscreenMonitor);
Expand Down Expand Up @@ -9544,10 +9568,8 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
_this2.videoEventHandlerList.push(fn);
addEvent(videoElement, key, fn);
});
domEvents.forEach(function (key) {
var fn = _this2._getEventHandler(key, { penetrate: true });
_this2.videoDomEventHandlerList.push(fn);
addEvent(videoElement, key, fn);
this._addDomEvents(videoElement, this.videoDomEventHandlerList, function (key) {
return _this2._getEventHandler(key, { penetrate: true });
});
this.videoElement = videoElement;
return videoElement;
Expand All @@ -9571,6 +9593,7 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
delete this.videoElement;
return videoElement;
}

/**
* each plugin has its own dom node, this function will create one or them.
* we support multiple kind of el
Expand Down Expand Up @@ -9626,10 +9649,8 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
// auto forward the event if this plugin can be penetrate
if (penetrate) {
this.__domEventHandlerList[id] = this.__domEventHandlerList[id] || [];
domEvents.forEach(function (key) {
var fn = _this4._getEventHandler(key, { penetrate: penetrate });
addEvent(node, key, fn);
_this4.__domEventHandlerList[id].push(fn);
this._addDomEvents(node, this.__domEventHandlerList[id], function (key) {
return _this4._getEventHandler(key, { penetrate: penetrate });
});
this.__videoExtendedNodes.push(node);
}
Expand All @@ -9640,6 +9661,7 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
outerElement.insertBefore(node, originElement.nextSibling);
return node;
}

/**
* remove plugin's dom
*/
Expand All @@ -9663,6 +9685,7 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
}
delete this.plugins[id];
}

/**
* Set zIndex for a plugins list
*/
Expand All @@ -9677,6 +9700,7 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
return setStyle(key.match(/^(videoElement|container)$/) ? _this6[key] : _this6.plugins[key], 'z-index', ++index$$1);
});
}

/**
* set attribute on our dom
* @param {string} attr attribute's name
Expand Down Expand Up @@ -9736,6 +9760,7 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
value: function focus() {
this.videoElement.focus();
}

/**
* function called when we distory
*/
Expand All @@ -9755,6 +9780,25 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
delete this.wrapper;
delete this.plugins;
}

/**
* bind all dom events on one element
* we will use passive mode if it support
*/

}, {
key: '_addDomEvents',
value: function _addDomEvents(element, handlerList, handlerGenerate) {
domEvents.forEach(function (key) {
var fn = handlerGenerate(key);
handlerList.push(fn);
if (passiveEvents.indexOf(key) > -1) {
addEvent(element, key, fn, false, { passive: true });
return;
}
addEvent(element, key, fn);
});
}
}, {
key: '_autoFocusToVideo',
value: function _autoFocusToVideo(element) {
Expand Down Expand Up @@ -9787,6 +9831,7 @@ var Dom = (_dec$6 = waituntil('__dispatcher.videoConfigReady'), _dec2$4 = before
this.__dispatcher.bus.triggerSync('fullscreenchange', evt);
}
}

/**
* get the event handler for dom to bind
*/
Expand Down Expand Up @@ -10745,7 +10790,7 @@ var Chimee = (_dec = autobindClass(), _dec(_class = (_class2 = (_temp = _class3
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'version', [frozen], {
enumerable: true,
initializer: function initializer() {
return '0.5.3';
return '0.5.4';
}
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'config', [frozen], {
enumerable: true,
Expand Down
Loading

0 comments on commit 31534f7

Please sign in to comment.