Firefox and Edge fixes

This commit is contained in:
Sam Potts 2016-08-21 19:44:46 +10:00
parent a8062354ec
commit 4610f4a8c9
4 changed files with 20 additions and 4 deletions

View File

@ -6,6 +6,7 @@ This version contains several ***breaking changes***:
- `setup()` has been reverted to pre v1.8.0 behaviour; meaning it will return the *instance* rather than the *element*. This is because the reference to the instance is no longer added to the original element (see below). - `setup()` has been reverted to pre v1.8.0 behaviour; meaning it will return the *instance* rather than the *element*. This is because the reference to the instance is no longer added to the original element (see below).
- The reference to the `plyr` instance is now added to the media element rather than original container. This is because if a container with multiple children was passed to `setup()` the references to all instances would have been added to the container, creating issues. I would recommend using the return value from `setup()` or the new `get()` method to access the instance. - The reference to the `plyr` instance is now added to the media element rather than original container. This is because if a container with multiple children was passed to `setup()` the references to all instances would have been added to the container, creating issues. I would recommend using the return value from `setup()` or the new `get()` method to access the instance.
- Players will always be wrapped in their own div now - this makes `setup()` and `destroy()` cleaner. This *may* break any custom styling based on DOM position. - Players will always be wrapped in their own div now - this makes `setup()` and `destroy()` cleaner. This *may* break any custom styling based on DOM position.
- Players no longer seek to 0 on 'ended' - this is to fix a bug with Microsoft Edge as it triggers 'ended' on media change for whatever reason. They'll never change ;-)
And some other changes and bug fixes: And some other changes and bug fixes:

View File

@ -73,8 +73,8 @@
</main> </main>
<!-- Plyr core script --> <!-- Plyr core script -->
<script src="../dist/plyr.js"></script> <!--<script src="../dist/plyr.js"></script>-->
<!--<script src="../src/js/plyr.js"></script>--> <script src="../src/js/plyr.js"></script>
<!-- Docs script --> <!-- Docs script -->
<script src="dist/demo.js"></script> <script src="dist/demo.js"></script>

4
dist/plyr.js vendored

File diff suppressed because one or more lines are too long

View File

@ -2903,6 +2903,12 @@
var code = getKeyCode(event), var code = getKeyCode(event),
pressed = event.type === 'keydown'; pressed = event.type === 'keydown';
// If the event is bubbled from the media element
// Firefox doesn't get the keycode for whatever reason
if (!_is.number(code)) {
return;
}
// Seek by the number keys // Seek by the number keys
function seekByKey() { function seekByKey() {
// Get current duration // Get current duration
@ -2920,6 +2926,14 @@
// Handle the key on keydown // Handle the key on keydown
// Reset on keyup // Reset on keyup
if (pressed) { if (pressed) {
// Which keycodes should we prevent default
var preventDefault = [48,49,50,51,52,53,54,56,57,32,75,38,40,77,39,37,70,67];
// If the code is found prevent default (e.g. prevent scrolling for arrows)
if (_inArray(preventDefault, code)) {
event.preventDefault();
}
switch(code) { switch(code) {
// 0-9 // 0-9
case 48: case 48:
@ -3155,6 +3169,7 @@
} }
// Proxy events to container // Proxy events to container
// Bubble up key events for Edge
_on(plyr.media, config.events.concat(['keyup', 'keydown']).join(' '), function(event) { _on(plyr.media, config.events.concat(['keyup', 'keydown']).join(' '), function(event) {
_triggerEvent(plyr.container, event.type, true); _triggerEvent(plyr.container, event.type, true);
}); });