Fix Sprite issue

This commit is contained in:
Sam Potts
2018-06-09 12:04:53 +10:00
parent 8e634862ff
commit 0c03accd41
14 changed files with 58 additions and 51 deletions
+1 -1
View File
@@ -4026,7 +4026,7 @@ singleton.Client = Client;
var player = new Plyr('#player', { var player = new Plyr('#player', {
debug: true, debug: true,
title: 'View From A Blue Moon', title: 'View From A Blue Moon',
iconUrl: '../dist/plyr.svg', // iconUrl: '../dist/plyr.svg',
keyboard: { keyboard: {
global: true global: true
}, },
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -50,7 +50,7 @@ import Raven from 'raven-js';
const player = new Plyr('#player', { const player = new Plyr('#player', {
debug: true, debug: true,
title: 'View From A Blue Moon', title: 'View From A Blue Moon',
iconUrl: '../dist/plyr.svg', // iconUrl: '../dist/plyr.svg',
keyboard: { keyboard: {
global: true, global: true,
}, },
+18 -14
View File
@@ -637,26 +637,25 @@ var utils = {
return; return;
} }
var prefix = 'cache-'; var prefix = 'cache';
var hasId = utils.is.string(id); var hasId = utils.is.string(id);
var isCached = false; var isCached = false;
var exists = function exists() { var exists = function exists() {
return document.querySelectorAll('#' + id).length; return document.getElementById(id) !== null;
}; };
function injectSprite(data) { var update = function update(container, data) {
container.innerHTML = data;
// Check again incase of race condition // Check again incase of race condition
if (hasId && exists()) { if (hasId && exists()) {
return; return;
} }
// Inject content
this.innerHTML = data;
// Inject the SVG to the body // Inject the SVG to the body
document.body.insertBefore(this, document.body.childNodes[0]); document.body.insertAdjacentElement('afterbegin', container);
} };
// Only load once if ID set // Only load once if ID set
if (!hasId || !exists()) { if (!hasId || !exists()) {
@@ -672,13 +671,12 @@ var utils = {
// Check in cache // Check in cache
if (useStorage) { if (useStorage) {
var cached = window.localStorage.getItem(prefix + id); var cached = window.localStorage.getItem(prefix + '-' + id);
isCached = cached !== null; isCached = cached !== null;
if (isCached) { if (isCached) {
var data = JSON.parse(cached); var data = JSON.parse(cached);
injectSprite.call(container, data.content); update(container, data.content);
return;
} }
} }
@@ -689,12 +687,12 @@ var utils = {
} }
if (useStorage) { if (useStorage) {
window.localStorage.setItem(prefix + id, JSON.stringify({ window.localStorage.setItem(prefix + '-' + id, JSON.stringify({
content: result content: result
})); }));
} }
injectSprite.call(container, result); update(container, result);
}).catch(function () {}); }).catch(function () {});
} }
}, },
@@ -4426,7 +4424,7 @@ var Listeners = function () {
// and if the focused element is not editable (e.g. text input) // and if the focused element is not editable (e.g. text input)
// and any that accept key input http://webaim.org/techniques/keyboard/ // and any that accept key input http://webaim.org/techniques/keyboard/
var focused = utils.getFocusElement(); var focused = utils.getFocusElement();
if (utils.is.element(focused) && utils.matches(focused, this.player.config.selectors.editable)) { if (utils.is.element(focused) && focused !== this.player.elements.inputs.seek && utils.matches(focused, this.player.config.selectors.editable)) {
return; return;
} }
@@ -4920,6 +4918,12 @@ var Listeners = function () {
on(this.player.elements.inputs.seek, 'mousedown mouseup keydown keyup touchstart touchend', function (event) { on(this.player.elements.inputs.seek, 'mousedown mouseup keydown keyup touchstart touchend', function (event) {
var seek = event.currentTarget; var seek = event.currentTarget;
var code = event.keyCode ? event.keyCode : event.which;
var eventType = event.type;
if ((eventType === 'keydown' || eventType === 'keyup') && code !== 39 && code !== 37) {
return;
}
// Was playing before? // Was playing before?
var play = seek.hasAttribute('play-on-seeked'); var play = seek.hasAttribute('play-on-seeked');
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+18 -13
View File
@@ -6020,26 +6020,25 @@ var utils = {
return; return;
} }
var prefix = 'cache-'; var prefix = 'cache';
var hasId = utils.is.string(id); var hasId = utils.is.string(id);
var isCached = false; var isCached = false;
var exists = function exists() { var exists = function exists() {
return document.querySelectorAll('#' + id).length; return document.getElementById(id) !== null;
}; };
function injectSprite(data) { var update = function update(container, data) {
container.innerHTML = data;
// Check again incase of race condition // Check again incase of race condition
if (hasId && exists()) { if (hasId && exists()) {
return; return;
} }
// Inject content
this.innerHTML = data;
// Inject the SVG to the body // Inject the SVG to the body
document.body.insertBefore(this, document.body.childNodes[0]); document.body.insertAdjacentElement('afterbegin', container);
} };
// Only load once if ID set // Only load once if ID set
if (!hasId || !exists()) { if (!hasId || !exists()) {
@@ -6055,12 +6054,12 @@ var utils = {
// Check in cache // Check in cache
if (useStorage) { if (useStorage) {
var cached = window.localStorage.getItem(prefix + id); var cached = window.localStorage.getItem(prefix + '-' + id);
isCached = cached !== null; isCached = cached !== null;
if (isCached) { if (isCached) {
var data = JSON.parse(cached); var data = JSON.parse(cached);
injectSprite.call(container, data.content); update(container, data.content);
return; return;
} }
} }
@@ -6072,12 +6071,12 @@ var utils = {
} }
if (useStorage) { if (useStorage) {
window.localStorage.setItem(prefix + id, JSON.stringify({ window.localStorage.setItem(prefix + '-' + id, JSON.stringify({
content: result content: result
})); }));
} }
injectSprite.call(container, result); update(container, result);
}).catch(function () {}); }).catch(function () {});
} }
}, },
@@ -9809,7 +9808,7 @@ var Listeners = function () {
// and if the focused element is not editable (e.g. text input) // and if the focused element is not editable (e.g. text input)
// and any that accept key input http://webaim.org/techniques/keyboard/ // and any that accept key input http://webaim.org/techniques/keyboard/
var focused = utils.getFocusElement(); var focused = utils.getFocusElement();
if (utils.is.element(focused) && utils.matches(focused, this.player.config.selectors.editable)) { if (utils.is.element(focused) && focused !== this.player.elements.inputs.seek && utils.matches(focused, this.player.config.selectors.editable)) {
return; return;
} }
@@ -10303,6 +10302,12 @@ var Listeners = function () {
on(this.player.elements.inputs.seek, 'mousedown mouseup keydown keyup touchstart touchend', function (event) { on(this.player.elements.inputs.seek, 'mousedown mouseup keydown keyup touchstart touchend', function (event) {
var seek = event.currentTarget; var seek = event.currentTarget;
var code = event.keyCode ? event.keyCode : event.which;
var eventType = event.type;
if ((eventType === 'keydown' || eventType === 'keyup') && code !== 39 && code !== 37) {
return;
}
// Was playing before? // Was playing before?
var play = seek.hasAttribute('play-on-seeked'); var play = seek.hasAttribute('play-on-seeked');
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+11 -13
View File
@@ -151,24 +151,23 @@ const utils = {
return; return;
} }
const prefix = 'cache-'; const prefix = 'cache';
const hasId = utils.is.string(id); const hasId = utils.is.string(id);
let isCached = false; let isCached = false;
const exists = () => document.querySelectorAll(`#${id}`).length; const exists = () => document.getElementById(id) !== null;
const update = (container, data) => {
container.innerHTML = data;
function injectSprite(data) {
// Check again incase of race condition // Check again incase of race condition
if (hasId && exists()) { if (hasId && exists()) {
return; return;
} }
// Inject content
this.innerHTML = data;
// Inject the SVG to the body // Inject the SVG to the body
document.body.insertBefore(this, document.body.childNodes[0]); document.body.insertAdjacentElement('afterbegin', container);
} };
// Only load once if ID set // Only load once if ID set
if (!hasId || !exists()) { if (!hasId || !exists()) {
@@ -184,13 +183,12 @@ const utils = {
// Check in cache // Check in cache
if (useStorage) { if (useStorage) {
const cached = window.localStorage.getItem(prefix + id); const cached = window.localStorage.getItem(`${prefix}-${id}`);
isCached = cached !== null; isCached = cached !== null;
if (isCached) { if (isCached) {
const data = JSON.parse(cached); const data = JSON.parse(cached);
injectSprite.call(container, data.content); update(container, data.content);
return;
} }
} }
@@ -204,14 +202,14 @@ const utils = {
if (useStorage) { if (useStorage) {
window.localStorage.setItem( window.localStorage.setItem(
prefix + id, `${prefix}-${id}`,
JSON.stringify({ JSON.stringify({
content: result, content: result,
}), }),
); );
} }
injectSprite.call(container, result); update(container, result);
}) })
.catch(() => {}); .catch(() => {});
} }