Skip to content

Commit

Permalink
feat: cache wideScrenn status in session
Browse files Browse the repository at this point in the history
  • Loading branch information
IronKinoko committed May 19, 2021
1 parent 4976b28 commit 10847cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/agefans/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ async function switchPart(href, $dom, push = true) {
try {
const vurl = await getVurlWithLocal(href)
player.src = vurl

showCurrentLink(vurl)
const $active = getActivedom()
$active.css('color', '')
Expand Down
10 changes: 10 additions & 0 deletions src/player/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class KPlayer {
this.isWideScreen = false
this.wideScreenBodyStyles = {}

this.statusSessionKey = 'k-player-status'

this._injectNext()
this._injectSreen()
this._initEvent()
Expand All @@ -63,6 +65,12 @@ class KPlayer {
const dom = document.querySelector('.plyr')
if (!this.isHoverControls) dom.classList.add('plyr--hide-controls')
}, 1000)

const status = window.sessionStorage.getItem(this.statusSessionKey)
if (status) {
window.sessionStorage.removeItem(this.statusSessionKey)
this._toggleFullscreen(true)
}
}

/** @private */
Expand Down Expand Up @@ -197,6 +205,8 @@ class KPlayer {
if (this.isWideScreen === bool) return
this.isWideScreen = bool

window.sessionStorage.setItem(this.statusSessionKey, this.isWideScreen)

this._setFullscreenIcon(this.isWideScreen)

if (this.isWideScreen) {
Expand Down

0 comments on commit 10847cc

Please sign in to comment.