diff options
author | Sam Potts <sam@potts.es> | 2018-06-13 00:02:55 +1000 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2018-06-13 00:02:55 +1000 |
commit | 392dfd024c505f5ae1bbb2f0d3e0793c251a1f35 (patch) | |
tree | aedb56d3945eaa10bf74e61902e16c08fd24914a /src/js/support.js | |
parent | 840e31a693462e7ed9f7644a13a0187d9e9d93a9 (diff) | |
download | plyr-392dfd024c505f5ae1bbb2f0d3e0793c251a1f35.tar.lz plyr-392dfd024c505f5ae1bbb2f0d3e0793c251a1f35.tar.xz plyr-392dfd024c505f5ae1bbb2f0d3e0793c251a1f35.zip |
Utils broken down into seperate files and exports
Diffstat (limited to 'src/js/support.js')
-rw-r--r-- | src/js/support.js | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/src/js/support.js b/src/js/support.js index 38212d9f..7eabae3c 100644 --- a/src/js/support.js +++ b/src/js/support.js @@ -2,7 +2,10 @@ // Plyr support checks // ========================================================================== -import utils from './utils'; +import { transitionEndEvent } from './utils/animation'; +import browser from './utils/browser'; +import { createElement } from './utils/elements'; +import is from './utils/is'; // Check for feature support const support = { @@ -15,7 +18,6 @@ const support = { check(type, provider, playsinline) { let api = false; let ui = false; - const browser = utils.getBrowser(); const canPlayInline = browser.isIPhone && playsinline && support.playsinline; switch (`${provider}:${type}`) { @@ -48,14 +50,11 @@ const support = { // Picture-in-picture support // Safari only currently - pip: (() => { - const browser = utils.getBrowser(); - return !browser.isIPhone && utils.is.function(utils.createElement('video').webkitSetPresentationMode); - })(), + pip: (() => !browser.isIPhone && is.function(createElement('video').webkitSetPresentationMode))(), // Airplay support // Safari only currently - airplay: utils.is.function(window.WebKitPlaybackTargetAvailabilityEvent), + airplay: is.function(window.WebKitPlaybackTargetAvailabilityEvent), // Inline playback support // https://webkit.org/blog/6784/new-video-policies-for-ios/ @@ -69,7 +68,7 @@ const support = { try { // Bail if no checking function - if (!this.isHTML5 || !utils.is.function(media.canPlayType)) { + if (!this.isHTML5 || !is.function(media.canPlayType)) { return false; } @@ -119,28 +118,6 @@ const support = { // Check for textTracks support textTracks: 'textTracks' in document.createElement('video'), - // Check for passive event listener support - // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md - // https://www.youtube.com/watch?v=NPM6172J22g - passiveListeners: (() => { - // Test via a getter in the options object to see if the passive property is accessed - let supported = false; - try { - const options = Object.defineProperty({}, 'passive', { - get() { - supported = true; - return null; - }, - }); - window.addEventListener('test', null, options); - window.removeEventListener('test', null, options); - } catch (e) { - // Do nothing - } - - return supported; - })(), - // <input type="range"> Sliders rangeInput: (() => { const range = document.createElement('input'); @@ -153,7 +130,7 @@ const support = { touch: 'ontouchstart' in document.documentElement, // Detect transitions support - transitions: utils.transitionEndEvent !== false, + transitions: transitionEndEvent !== false, // Reduced motion iOS & MacOS setting // https://webkit.org/blog/7551/responsive-design-for-motion/ |