Skip to content

Commit

Permalink
feat(core): change ios fullscreen toggle to use the playback element
Browse files Browse the repository at this point in the history
  • Loading branch information
towerz committed Dec 6, 2019
1 parent 18630d3 commit dc2f7d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
7 changes: 3 additions & 4 deletions src/components/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,6 @@ export default class Core extends UIObject {

if (!fullscreenElement) return false

if (Browser.isiOS)
return fullscreenElement === (this.activeContainer && this.activeContainer.el || this.el)

const playbackEl = this.activePlayback && this.activePlayback.el
return (fullscreenElement === this.el) || (fullscreenElement === playbackEl)
}
Expand All @@ -317,7 +314,9 @@ export default class Core extends UIObject {
Fullscreen.cancelFullscreen()
!Browser.isiOS && this.$el.removeClass('fullscreen nocursor')
} else {
Fullscreen.requestFullscreen(Browser.isiOS ? this.activeContainer.el : this.el)
const fullscreenEl = Browser.isiOS ? this.activePlayback && this.activePlayback.el : this.el
if (!fullscreenEl) return
Fullscreen.requestFullscreen(fullscreenEl)
!Browser.isiOS && this.$el.addClass('fullscreen')
}
}
Expand Down
26 changes: 14 additions & 12 deletions test/components/core_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,19 @@ describe('Core', function() {
browserStub.restore()
})

it('returns false if there\'s no active container', () => {
fullscreenElementStub.returns(undefined)
it('returns false if there\'s no active playback', () => {
this.core.activeContainer = undefined

expect(this.core.isFullscreen()).to.equal(false)
})

it('returns false if the fullscreen element is from the active container', () => {
const fakeCurrentContainer = document.createElement('div')
fakeCurrentContainer.setAttribute('id', 'fakeCurrentContainer')
this.core.activeContainer = { el: fakeCurrentContainer }
it('returns true if the fullscreen element is from the active playback', () => {
const el = document.createElement('div')
el.setAttribute('id', 'fakePlayback')
const playback = { el }
this.core.activeContainer = { playback }

fullscreenElementStub.returns(this.core.activeContainer.el)
fullscreenElementStub.returns(el)

expect(this.core.isFullscreen()).to.equal(true)
})
Expand Down Expand Up @@ -159,14 +160,15 @@ describe('Core', function() {
browserStub.restore()
})

it('calls Fullscreen.requestFullscreen with currentContainer element', () => {
const fakeCurrentContainer = document.createElement('div')
fakeCurrentContainer.setAttribute('id', 'fakeCurrentContainer')
this.core.activeContainer = { el: fakeCurrentContainer }
it('calls Fullscreen.requestFullscreen with activePlayback element', () => {
const el = document.createElement('div')
el.setAttribute('id', 'fakePlayback')
const playback = { el }
this.core.activeContainer = { playback }

this.core.toggleFullscreen()

expect(fullScreenSpy).to.have.been.calledWith(this.core.activeContainer.el)
expect(fullScreenSpy).to.have.been.calledWith(el)
})
})
})
Expand Down

0 comments on commit dc2f7d7

Please sign in to comment.