添加自动隐藏光标

This commit is contained in:
Harvey Zack committed 2018-11-05 15:35:09 +08:00
1 parent 617fd9681e
commit d9fd20bdf3
14 files changed
+127 -27

No files matched your search

+61 -14
View File
@@ -407,6 +407,21 @@
return item !== target;
});
}
function debounce(func, wait, scope) {
var timeout;
return function fn() {
var context = scope || this;
var args = arguments;
var later = function later() {
timeout = null;
func.apply(context, args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
var optionValidator = createCommonjsModule(function (module, exports) {
!function(r,t){module.exports=t();}(commonjsGlobal,function(){function c(r){return (c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var u=Object.prototype.toString,i=function(r){if(void 0===r)return "undefined";if(null===r)return "null";var t,e,n,o,a,i=c(r);if("boolean"===i)return "boolean";if("string"===i)return "string";if("number"===i)return "number";if("symbol"===i)return "symbol";if("function"===i)return "GeneratorFunction"===f(r)?"generatorfunction":"function";if(t=r,Array.isArray?Array.isArray(t):t instanceof Array)return "array";if(function(r){if(r.constructor&&"function"==typeof r.constructor.isBuffer)return r.constructor.isBuffer(r);return !1}(r))return "buffer";if(function(r){try{if("number"==typeof r.length&&"function"==typeof r.callee)return !0}catch(r){if(-1!==r.message.indexOf("callee"))return !0}return !1}(r))return "arguments";if((e=r)instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate)return "date";if((n=r)instanceof Error||"string"==typeof n.message&&n.constructor&&"number"==typeof n.constructor.stackTraceLimit)return "error";if((o=r)instanceof RegExp||"string"==typeof o.flags&&"boolean"==typeof o.ignoreCase&&"boolean"==typeof o.multiline&&"boolean"==typeof o.global)return "regexp";switch(f(r)){case"Symbol":return "symbol";case"Promise":return "promise";case"WeakMap":return "weakmap";case"WeakSet":return "weakset";case"Map":return "map";case"Set":return "set";case"Int8Array":return "int8array";case"Uint8Array":return "uint8array";case"Uint8ClampedArray":return "uint8clampedarray";case"Int16Array":return "int16array";case"Uint16Array":return "uint16array";case"Int32Array":return "int32array";case"Uint32Array":return "uint32array";case"Float32Array":return "float32array";case"Float64Array":return "float64array"}if("function"==typeof(a=r).throw&&"function"==typeof a.return&&"function"==typeof a.next)return "generator";switch(i=u.call(r)){case"[object Object]":return "object";case"[object Map Iterator]":return "mapiterator";case"[object Set Iterator]":return "setiterator";case"[object String Iterator]":return "stringiterator";case"[object Array Iterator]":return "arrayiterator"}return i.slice(8,-1).toLowerCase().replace(/\s/g,"")};function f(r){return r.constructor?r.constructor.name:null}function a(r,t){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:["option"];for(var n in y(r,t,e),l(r,t,e),p(r,t,e),t)if(t.hasOwnProperty(n)){var o=r[n],a=t[n],i=e.concat(n);if(s(r,n,a,i))continue;y(o,a,i),l(o,a,i),p(o,a,i);}}function s(r,t,e,n){if(!Object.prototype.hasOwnProperty.call(r,t)){if(!0===e.__required__||!0===e.required)throw new TypeError("'".concat(n.join("."),"' is required"));return !0}}function y(r,t,e){var n;if("string"===i(t)?n=t:t.__type__?n=t.__type__:t.type&&(n=t.type),n&&"string"===i(n)){n=n.trim().toLowerCase();var o=i(r),a=o===n;if(-1<n.indexOf("|"))a=n.split("|").filter(Boolean).some(function(r){return o===r.trim()});if(!a)throw new TypeError("'".concat(e.join("."),"' require '").concat(n,"' type, but got '").concat(o,"'"))}}function l(r,t,e){var n;if(t.___validator__?n=t.___validator__:t.validator&&(n=t.validator),"function"===i(n)){var o=n(e,r,i(r));if(!0!==o)throw new TypeError("The scheme for '".concat(e.join("."),"' validator function require return true, but got '").concat(o,"'"))}}function p(r,t,e){var n;if(t.___child__?n=t.___child__:t.child&&(n=t.child),"object"===i(n)){var o=i(r);"object"===o?a(r,n,e):"array"===o&&r.forEach(function(r,t){a(r,n,e.concat(t));});}}return a.kindOf=i,window.optionValidator=a});
@@ -760,22 +775,13 @@
function eventInit(art, player) {
var option = art.option,
_art$events = art.events,
proxy = _art$events.proxy,
hover = _art$events.hover,
proxy = art.events.proxy,
_art$refs = art.refs,
$player = _art$refs.$player,
$video = _art$refs.$video,
i18n = art.i18n,
notice = art.notice;
var firstCanplay = false;
hover($player, function () {
$player.classList.add('artplayer-hover');
art.emit('hoverenter');
}, function () {
$player.classList.remove('artplayer-hover');
art.emit('hoverleave');
});
proxy($video, 'click', function () {
player.toggle();
});
@@ -1009,6 +1015,16 @@
}
}
});
Object.defineProperty(player, 'resetPlaybackRate', {
value: function value() {
var $player = art.refs.$player;
var playbackRate = $player.dataset.playbackRate;
if (playbackRate) {
player.playbackRate(Number(playbackRate));
}
}
});
}
function aspectRatioMix(art, player) {
@@ -1076,8 +1092,6 @@
value: function value() {
var $player = art.refs.$player;
var aspectRatio = $player.dataset.aspectRatio;
console.log($player.dataset);
console.log(aspectRatio);
if (aspectRatio) {
player.aspectRatio(aspectRatio.split(':'));
@@ -1292,6 +1306,7 @@
}
player.resetAspectRatio();
art.emit('fullscreenWeb', _this.state);
});
}
}]);
@@ -1553,10 +1568,12 @@
subtitle.hide();
setStyle(_this.$subtitle, 'opacity', '1');
tooltip(_this.$subtitle, i18n.get('Show subtitle'));
art.emit('subtitle:hide');
} else {
subtitle.show();
setStyle(_this.$subtitle, 'opacity', '0.8');
tooltip(_this.$subtitle, i18n.get('Hide subtitle'));
art.emit('subtitle:show');
}
});
}
@@ -1747,10 +1764,12 @@
setting.hide();
setStyle(_this.$setting, 'opacity', '1');
tooltip(_this.$setting, i18n.get('Show setting'));
art.emit('setting:hide');
} else {
setting.show();
setStyle(_this.$setting, 'opacity', '0.8');
tooltip(_this.$setting, i18n.get('Hide setting'));
art.emit('setting:show');
}
});
}
@@ -1881,6 +1900,8 @@
proxy(this.$screenshot, 'click', function () {
try {
_this.captureFrame();
art.emit('screenshot');
} catch (error) {
notice.show(error);
}
@@ -2690,19 +2711,45 @@
this.destroyEvents = [];
this.proxy = this.proxy.bind(this);
this.hover = this.hover.bind(this);
this.init();
}
createClass(Events, [{
key: "init",
value: function init() {
var _this = this;
var $player = this.art.refs.$player;
this.hover($player, function () {
$player.classList.add('artplayer-hover');
_this.art.emit('hoverenter');
}, function () {
$player.classList.remove('artplayer-hover');
$player.classList.remove('artplayer-hide-cursor');
_this.art.emit('hoverleave');
});
var hideCursor = debounce(function () {
$player.classList.add('artplayer-hide-cursor');
}, 5000);
this.proxy($player, 'mousemove', function () {
$player.classList.remove('artplayer-hide-cursor');
hideCursor();
});
}
}, {
key: "proxy",
value: function proxy(target, name, callback) {
var _this = this;
var _this2 = this;
var option = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
if (Array.isArray(name)) {
name.forEach(function (item) {
return _this.proxy(target, item, callback, option);
return _this2.proxy(target, item, callback, option);
});
return;
}
target.addEventListener(name, callback, option);