Skip to content

Commit

Permalink
fix utils.isMobile
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jan 11, 2018
1 parent 1002347 commit 15631ec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/js/DPlayer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import utils, { isMobile } from './utils';
import utils from './utils';
import handleOption from './options';
import i18n from './i18n';
import Template from './template';
Expand Down Expand Up @@ -48,7 +48,7 @@ class DPlayer {
if (this.options.live) {
this.container.classList.add('dplayer-live');
}
if (isMobile) {
if (utils.isMobile) {
this.container.classList.add('dplayer-mobile');
}
this.arrow = this.container.offsetWidth <= 500;
Expand Down Expand Up @@ -83,10 +83,10 @@ class DPlayer {
this.template.danmakuLoading.style.display = 'none';

// autoplay
if (this.options.autoplay && !isMobile) {
if (this.options.autoplay && !utils.isMobile) {
this.play();
}
else if (isMobile) {
else if (utils.isMobile) {
this.pause();
}
}, 0);
Expand Down Expand Up @@ -128,10 +128,10 @@ class DPlayer {

if (!this.danmaku) {
// autoplay
if (this.options.autoplay && !isMobile) {
if (this.options.autoplay && !utils.isMobile) {
this.play();
}
else if (isMobile) {
else if (utils.isMobile) {
this.pause();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/js/controller.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import utils, { isMobile } from './utils';
import utils from './utils';
import Thumbnails from './thumbnails';

class Controller {
constructor (player) {
this.player = player;

this.autoHideTimer = 0;
if (!isMobile) {
if (!utils.isMobile) {
this.player.container.addEventListener('mousemove', () => {
this.setAutoHide();
});
Expand All @@ -30,7 +30,7 @@ class Controller {
this.player.toggle();
});

if (!isMobile) {
if (!utils.isMobile) {
this.player.template.videoWrap.addEventListener('click', () => {
this.player.toggle();
});
Expand Down
4 changes: 2 additions & 2 deletions src/js/options.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* global DPLAYER_VERSION GIT_HASH */
import defaultApiBackend from './api.js';
import utils from './utils';

export default (options) => {
const isMobile = /mobile/i.test(window.navigator.userAgent);
// compatibility: some mobile browsers don't suppose autoplay
if (isMobile) {
if (utils.isMobile) {
options.autoplay = false;
}

Expand Down

0 comments on commit 15631ec

Please sign in to comment.