react-tj-vimeo
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -13,4 +13,2 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _player = require('@vimeo/player'); | ||
@@ -49,3 +47,3 @@ | ||
videoId: props.videoId, | ||
isFullscreen: props.isFullscreen | ||
supportFS: props.supportFS | ||
}; | ||
@@ -57,21 +55,40 @@ | ||
/** | ||
* componentDidMount | ||
*/ | ||
_createClass(Vimeo, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.initPlayer(); | ||
this.player = new _player2.default(this.iframe); | ||
this.addEvents(this.player); | ||
} | ||
/** | ||
* componentWillUnmount | ||
*/ | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
this.player.off('loaded'); | ||
this.player.off('play'); | ||
this.player.off('pause'); | ||
this.player.off('ended'); | ||
this.player.off('progress'); | ||
this.player.off('timeupdate'); | ||
this.player.off('seeked'); | ||
this.player.off('volumechange'); | ||
this.player.off('error'); | ||
this.removeEvents(this.player); | ||
} | ||
/** | ||
* shouldComponentUpdate | ||
*/ | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate() { | ||
return false; | ||
} | ||
/** | ||
* render | ||
*/ | ||
}, { | ||
key: 'render', | ||
@@ -88,7 +105,7 @@ value: function render() { | ||
frameBorder: '0', | ||
allowFullScreen: this.state.isFullscreen }); | ||
allowFullScreen: this.state.supportFS }); | ||
} | ||
}, { | ||
key: 'initPlayer', | ||
value: function initPlayer() { | ||
key: 'addEvents', | ||
value: function addEvents(player) { | ||
var _this3 = this; | ||
@@ -107,18 +124,29 @@ | ||
// event listeners | ||
this.player = new _player2.default(this.iframe); | ||
// event listeners | ||
this.player.on('loaded', function (res) { | ||
onLoaded(_this3.player, res.id); | ||
player.on('loaded', function (res) { | ||
onLoaded(player, _this3.iframe); | ||
}); | ||
this.player.on('play', onPlay); | ||
this.player.on('pause', onPause); | ||
this.player.on('ended', onEnded); | ||
this.player.on('progress', onProgress); | ||
this.player.on('seeked', onSeeked); | ||
this.player.on('timeupdate', onTimeupdate); | ||
this.player.on('volumechange', onVolumeChange); | ||
this.player.on('error', onError); | ||
player.on('play', onPlay); | ||
player.on('pause', onPause); | ||
player.on('ended', onEnded); | ||
player.on('progress', onProgress); | ||
player.on('seeked', onSeeked); | ||
player.on('timeupdate', onTimeupdate); | ||
player.on('volumechange', onVolumeChange); | ||
player.on('error', onError); | ||
} | ||
}, { | ||
key: 'removeEvents', | ||
value: function removeEvents(player) { | ||
player.off('loaded'); | ||
player.off('play'); | ||
player.off('pause'); | ||
player.off('ended'); | ||
player.off('progress'); | ||
player.off('timeupdate'); | ||
player.off('seeked'); | ||
player.off('volumechange'); | ||
player.off('error'); | ||
} | ||
}]); | ||
@@ -125,0 +153,0 @@ |
{ | ||
"name": "react-tj-vimeo", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "Tony Jin <jsveron23@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "TJ Vimeo API for React", |
8206
144