Skip to content

Commit

Permalink
Detect fullscreen changes on Safari.
Browse files Browse the repository at this point in the history
  • Loading branch information
hvianna committed Oct 7, 2020
1 parent ade8484 commit 8d13370
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,8 @@ Reason | Description
`'resize'` | browser window or canvas container element were resized
`'user'` | canvas dimensions changed by user script, via [`height`](#height-number) and [`width`](#width-number) properties, [`setCanvasSize()`](#setcanvassize-width-height-) or [`setOptions()`](#setoptions-options-) methods

?> As of [version 2.5.0](https://github.com/hvianna/audioMotion-analyzer/releases/tag/2.5.0), a callback is triggered only when canvas dimensions *effectively* change
from the previous state, and the `'resize'` reason is no longer sent on fullscreen changes (except on Safari, see below).

!> On **Safari**, fullscreen changes will be reported as `'resize'` to the callback and `'fschange'` will never be issued, due to lack of support for the [*fullscreenchange* event](https://developer.mozilla.org/en-US/docs/Web/API/Element/fullscreenchange_event).
?> As of [version 2.5.0](https://github.com/hvianna/audioMotion-analyzer/releases/tag/2.5.0), the `'resize'` reason is no longer sent on fullscreen changes and
a callback is triggered only when canvas dimensions *effectively* change from the previous state.

Usage example:

Expand Down
5 changes: 5 additions & 0 deletions src/audioMotion-analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,11 @@ export default class AudioMotionAnalyzer {
// calculate bar positions and led options
this._precalculateBarPositions();

// detect fullscreen changes (for Safari)
if ( this._fsStatus !== undefined && this._fsStatus !== isFullscreen )
reason = 'fschange';
this._fsStatus = isFullscreen;

// call the callback function, if defined
if ( this.onCanvasResize )
this.onCanvasResize( reason, this );
Expand Down

0 comments on commit 8d13370

Please sign in to comment.