1
1
2
2
/**
3
- * chimee v0.9.0
3
+ * chimee v0.9.1
4
4
* (c) 2017-2018 toxic-johann
5
5
* Released under MIT
6
6
*/
9
9
10
10
function _interopDefault ( ex ) { return ( ex && ( typeof ex === 'object' ) && 'default' in ex ) ? ex [ 'default' ] : ex ; }
11
11
12
- var _Object$defineProperty = _interopDefault ( require ( 'babel-runtime/core-js/object/define-property' ) ) ;
13
12
var _Object$getOwnPropertyDescriptor = _interopDefault ( require ( 'babel-runtime/core-js/object/get-own-property-descriptor' ) ) ;
14
- var _Object$getPrototypeOf = _interopDefault ( require ( 'babel-runtime/core-js/object/get-prototype-of' ) ) ;
13
+ var _Map = _interopDefault ( require ( 'babel-runtime/core-js/map' ) ) ;
14
+ var _toConsumableArray = _interopDefault ( require ( 'babel-runtime/helpers/toConsumableArray' ) ) ;
15
+ var _Promise = _interopDefault ( require ( 'babel-runtime/core-js/promise' ) ) ;
15
16
var _classCallCheck = _interopDefault ( require ( 'babel-runtime/helpers/classCallCheck' ) ) ;
16
17
var _createClass = _interopDefault ( require ( 'babel-runtime/helpers/createClass' ) ) ;
18
+ var chimeeHelper = require ( 'chimee-helper' ) ;
19
+ var toxicDecorators = require ( 'toxic-decorators' ) ;
20
+ var _Object$defineProperty = _interopDefault ( require ( 'babel-runtime/core-js/object/define-property' ) ) ;
21
+ var _Number$isNaN = _interopDefault ( require ( 'babel-runtime/core-js/number/is-nan' ) ) ;
22
+ var _Object$keys = _interopDefault ( require ( 'babel-runtime/core-js/object/keys' ) ) ;
23
+ var _JSON$stringify = _interopDefault ( require ( 'babel-runtime/core-js/json/stringify' ) ) ;
24
+ var _defineProperty = _interopDefault ( require ( 'babel-runtime/helpers/defineProperty' ) ) ;
25
+ var _typeof = _interopDefault ( require ( 'babel-runtime/helpers/typeof' ) ) ;
26
+ var _Object$getPrototypeOf = _interopDefault ( require ( 'babel-runtime/core-js/object/get-prototype-of' ) ) ;
17
27
var _possibleConstructorReturn = _interopDefault ( require ( 'babel-runtime/helpers/possibleConstructorReturn' ) ) ;
18
28
var _get = _interopDefault ( require ( 'babel-runtime/helpers/get' ) ) ;
19
29
var _inherits = _interopDefault ( require ( 'babel-runtime/helpers/inherits' ) ) ;
20
- var _toConsumableArray = _interopDefault ( require ( 'babel-runtime/helpers/toConsumableArray ' ) ) ;
30
+ var esFullscreen = _interopDefault ( require ( 'es-fullscreen ' ) ) ;
21
31
var _slicedToArray = _interopDefault ( require ( 'babel-runtime/helpers/slicedToArray' ) ) ;
22
32
var _Object$entries = _interopDefault ( require ( 'babel-runtime/core-js/object/entries' ) ) ;
23
33
var _Object$assign = _interopDefault ( require ( 'babel-runtime/core-js/object/assign' ) ) ;
24
- var _Promise = _interopDefault ( require ( 'babel-runtime/core-js/promise' ) ) ;
25
- var _typeof = _interopDefault ( require ( 'babel-runtime/helpers/typeof' ) ) ;
26
- var chimeeHelper = require ( 'chimee-helper' ) ;
27
34
var ChimeeKernel = _interopDefault ( require ( 'chimee-kernel' ) ) ;
28
- var _Map = _interopDefault ( require ( 'babel-runtime/core-js/map' ) ) ;
29
- var toxicDecorators = require ( 'toxic-decorators' ) ;
30
- var _Object$keys = _interopDefault ( require ( 'babel-runtime/core-js/object/keys' ) ) ;
31
- var _JSON$stringify = _interopDefault ( require ( 'babel-runtime/core-js/json/stringify' ) ) ;
32
- var _defineProperty = _interopDefault ( require ( 'babel-runtime/helpers/defineProperty' ) ) ;
33
- var _Number$isNaN = _interopDefault ( require ( 'babel-runtime/core-js/number/is-nan' ) ) ;
34
- var esFullscreen = _interopDefault ( require ( 'es-fullscreen' ) ) ;
35
35
36
36
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' ] ;
37
37
var videoReadOnlyProperties = [ 'buffered' , 'currentSrc' , 'duration' , 'error' , 'ended' , 'networkState' , 'paused' , 'readyState' , 'seekable' , 'sinkId' , 'controlsList' , 'tabIndex' , 'dataset' , 'offsetHeight' , 'offsetLeft' , 'offsetParent' , 'offsetTop' , 'offsetWidth' ] ;
@@ -622,15 +622,15 @@ function accessorVideoAttribute(attribute) {
622
622
} ,
623
623
_set = _ref . set ,
624
624
_get$$1 = _ref . get ,
625
- isBoolean$$1 = _ref . isBoolean ;
625
+ isBoolean = _ref . isBoolean ;
626
626
627
627
return toxicDecorators . accessor ( {
628
628
get : function get ( value ) {
629
629
return this . dispatcher . videoConfigReady && this . inited ? this . dom . videoElement [ _get$$1 ] : value ;
630
630
} ,
631
631
set : function set ( value ) {
632
632
if ( ! this . dispatcher . videoConfigReady ) return value ;
633
- var val = isBoolean$$1 ? value ? '' : undefined
633
+ var val = isBoolean ? value ? '' : undefined
634
634
/* istanbul ignore next */
635
635
: value === null ? undefined : value ;
636
636
this . dom . setAttr ( 'video' , _set , val ) ;
@@ -641,15 +641,15 @@ function accessorVideoAttribute(attribute) {
641
641
} ) ;
642
642
}
643
643
644
- function accessorCustomAttribute ( attribute , isBoolean$$1 ) {
644
+ function accessorCustomAttribute ( attribute , isBoolean ) {
645
645
return toxicDecorators . accessor ( {
646
646
get : function get ( value ) {
647
647
var attrValue = this . dom . getAttr ( 'video' , attribute ) ;
648
- return this . dispatcher . videoConfigReady && this . inited ? isBoolean$$1 ? ! ! attrValue : attrValue : value ;
648
+ return this . dispatcher . videoConfigReady && this . inited ? isBoolean ? ! ! attrValue : attrValue : value ;
649
649
} ,
650
650
set : function set ( value ) {
651
651
if ( ! this . dispatcher . videoConfigReady ) return value ;
652
- var val = isBoolean$$1 ? value || undefined : value === null ? undefined : value ;
652
+ var val = isBoolean ? value || undefined : value === null ? undefined : value ;
653
653
this . dom . setAttr ( 'video' , attribute , val ) ;
654
654
return value ;
655
655
}
@@ -1462,7 +1462,7 @@ var Plugin = (_dec$3 = toxicDecorators.autobindClass(), _dec$3(_class$3 = functi
1462
1462
var _this = _possibleConstructorReturn ( this , ( Plugin . __proto__ || _Object$getPrototypeOf ( Plugin ) ) . call ( this ) ) ;
1463
1463
1464
1464
_this . destroyed = false ;
1465
- _this . VERSION = '0.9.0 ' ;
1465
+ _this . VERSION = '0.9.1 ' ;
1466
1466
_this . __operable = true ;
1467
1467
_this . __level = 0 ;
1468
1468
@@ -1860,7 +1860,9 @@ var Dom = (_dec$4 = toxicDecorators.waituntil('__dispatcher.videoConfigReady'),
1860
1860
_createClass ( Dom , [ {
1861
1861
key : 'installVideo' ,
1862
1862
value : function installVideo ( videoElement ) {
1863
- var _this2 = this ;
1863
+ var _ref = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ,
1864
+ _ref$bindEvent = _ref . bindEvent ,
1865
+ bindEvent = _ref$bindEvent === undefined ? true : _ref$bindEvent ;
1864
1866
1865
1867
this . __videoExtendedNodes . push ( videoElement ) ;
1866
1868
chimeeHelper . setAttr ( videoElement , 'tabindex' , - 1 ) ;
@@ -1885,6 +1887,15 @@ var Dom = (_dec$4 = toxicDecorators.waituntil('__dispatcher.videoConfigReady'),
1885
1887
if ( this . container . parentElement !== this . wrapper ) {
1886
1888
chimeeHelper . $ ( this . wrapper ) . append ( this . container ) ;
1887
1889
}
1890
+ if ( bindEvent ) this . bindVideoEvents ( videoElement ) ;
1891
+ this . videoElement = videoElement ;
1892
+ return videoElement ;
1893
+ }
1894
+ } , {
1895
+ key : 'bindVideoEvents' ,
1896
+ value : function bindVideoEvents ( videoElement ) {
1897
+ var _this2 = this ;
1898
+
1888
1899
videoEvents . forEach ( function ( key ) {
1889
1900
var fn = function fn ( ) {
1890
1901
var _dispatcher$bus3 ;
@@ -1901,8 +1912,6 @@ var Dom = (_dec$4 = toxicDecorators.waituntil('__dispatcher.videoConfigReady'),
1901
1912
this . _addDomEvents ( videoElement , this . videoDomEventHandlerList , function ( key ) {
1902
1913
return _this2 . _getEventHandler ( key , { penetrate : true } ) ;
1903
1914
} ) ;
1904
- this . videoElement = videoElement ;
1905
- return videoElement ;
1906
1915
}
1907
1916
} , {
1908
1917
key : 'removeVideo' ,
@@ -2040,25 +2049,25 @@ var Dom = (_dec$4 = toxicDecorators.waituntil('__dispatcher.videoConfigReady'),
2040
2049
2041
2050
} , {
2042
2051
key : 'setAttr' ,
2043
- value : function setAttr$$1 ( target , attr , val ) {
2052
+ value : function setAttr ( target , attr , val ) {
2044
2053
// $FlowFixMe: flow do not support computed property/element on class, which is silly here.
2045
2054
chimeeHelper . setAttr ( this [ target ] , attr , val ) ;
2046
2055
}
2047
2056
} , {
2048
2057
key : 'getAttr' ,
2049
- value : function getAttr$$1 ( target , attr ) {
2058
+ value : function getAttr ( target , attr ) {
2050
2059
// $FlowFixMe: flow do not support computed property/element on class, which is silly here.
2051
2060
return chimeeHelper . getAttr ( this [ target ] , attr ) ;
2052
2061
}
2053
2062
} , {
2054
2063
key : 'setStyle' ,
2055
- value : function setStyle$$1 ( target , attr , val ) {
2064
+ value : function setStyle ( target , attr , val ) {
2056
2065
// $FlowFixMe: flow do not support computed property/element on class, which is silly here.
2057
2066
chimeeHelper . setStyle ( this [ target ] , attr , val ) ;
2058
2067
}
2059
2068
} , {
2060
2069
key : 'getStyle' ,
2061
- value : function getStyle$$1 ( target , attr ) {
2070
+ value : function getStyle ( target , attr ) {
2062
2071
// $FlowFixMe: flow do not support computed property/element on class, which is silly here.
2063
2072
return chimeeHelper . getStyle ( this [ target ] , attr ) ;
2064
2073
}
@@ -2169,10 +2178,10 @@ var Dom = (_dec$4 = toxicDecorators.waituntil('__dispatcher.videoConfigReady'),
2169
2178
2170
2179
} , {
2171
2180
key : '_getEventHandler' ,
2172
- value : function _getEventHandler ( key , _ref ) {
2181
+ value : function _getEventHandler ( key , _ref2 ) {
2173
2182
var _this8 = this ;
2174
2183
2175
- var penetrate = _ref . penetrate ;
2184
+ var penetrate = _ref2 . penetrate ;
2176
2185
2177
2186
if ( ! penetrate || [ 'mouseenter' , 'mouseleave' ] . indexOf ( key ) < 0 ) {
2178
2187
return function ( ) {
@@ -2449,12 +2458,12 @@ var Dispatcher = (_dec$5 = toxicDecorators.before(convertNameIntoId), _dec2$4 =
2449
2458
if ( ! chimeeHelper . isString ( option . alias ) ) option . alias = undefined ;
2450
2459
var _option = option ,
2451
2460
name = _option . name ,
2452
- alias$$1 = _option . alias ;
2461
+ alias = _option . alias ;
2453
2462
2454
- option . name = alias$$1 || name ;
2463
+ option . name = alias || name ;
2455
2464
delete option . alias ;
2456
2465
var key = chimeeHelper . camelize ( name ) ;
2457
- var id = chimeeHelper . camelize ( alias$$1 || name ) ;
2466
+ var id = chimeeHelper . camelize ( alias || name ) ;
2458
2467
var pluginOption = option ;
2459
2468
var pluginConfig = Dispatcher . getPluginConfig ( key ) ;
2460
2469
if ( chimeeHelper . isEmpty ( pluginConfig ) ) throw new TypeError ( 'You have not installed plugin ' + key ) ;
@@ -2696,7 +2705,7 @@ var Dispatcher = (_dec$5 = toxicDecorators.before(convertNameIntoId), _dec2$4 =
2696
2705
var oldKernel = this . kernel ;
2697
2706
var originVideoConfig = chimeeHelper . deepClone ( this . videoConfig ) ;
2698
2707
this . dom . removeVideo ( ) ;
2699
- this . dom . installVideo ( video ) ;
2708
+ this . dom . installVideo ( video , { bindEvent : false } ) ;
2700
2709
// as we will reset the currentVideoConfig on the new video
2701
2710
// it will trigger the watch function as they maybe differnet
2702
2711
// because video config will return the real situation
@@ -2721,6 +2730,11 @@ var Dispatcher = (_dec$5 = toxicDecorators.before(convertNameIntoId), _dec2$4 =
2721
2730
_Object$assign ( this . videoConfig , { isLive : isLive , box : box , preset : preset , kernels : kernels } ) ;
2722
2731
// const config = {}
2723
2732
oldKernel . destroy ( ) ;
2733
+ // delay video event binding
2734
+ // so that people can't feel the default value change
2735
+ setTimeout ( function ( ) {
2736
+ return _this3 . dom . bindVideoEvents ( video ) ;
2737
+ } ) ;
2724
2738
}
2725
2739
/**
2726
2740
* destroy function called when dispatcher destroyed
@@ -3231,6 +3245,15 @@ var Chimee = (_dec$6 = toxicDecorators.autobindClass(), _dec$6(_class$7 = (_clas
3231
3245
value : function destroy ( ) {
3232
3246
_get ( Chimee . prototype . __proto__ || _Object$getPrototypeOf ( Chimee . prototype ) , '__destroy' , this ) . call ( this ) ;
3233
3247
this . __dispatcher . destroy ( ) ;
3248
+ // $FlowFixMe: normal obejct define
3249
+ Object . defineProperty ( this , '__dispatcher' , {
3250
+ get : function get ( ) {
3251
+ throw new Error ( 'This instance has been destroyed.' ) ;
3252
+ } ,
3253
+
3254
+ enumerable : true ,
3255
+ configurable : true
3256
+ } ) ;
3234
3257
this . destroyed = true ;
3235
3258
}
3236
3259
} , {
@@ -3263,7 +3286,7 @@ var Chimee = (_dec$6 = toxicDecorators.autobindClass(), _dec$6(_class$7 = (_clas
3263
3286
} ) , _descriptor2$1 = _applyDecoratedDescriptor$6 ( _class2$1 . prototype , 'version' , [ toxicDecorators . frozen ] , {
3264
3287
enumerable : true ,
3265
3288
initializer : function initializer ( ) {
3266
- return '0.9.0 ' ;
3289
+ return '0.9.1 ' ;
3267
3290
}
3268
3291
} ) , _descriptor3$1 = _applyDecoratedDescriptor$6 ( _class2$1 . prototype , 'config' , [ toxicDecorators . frozen ] , {
3269
3292
enumerable : true ,
0 commit comments