Developers

wp.hooks.doAction( 'riff.view', detail, api )

Fires when a view opens or closes, Riff's own included, and again for an open view when the track changes. A view's script fills it here, or in the render it was given.

Also dispatched as the riff:view event on #riff, with the same detail. The event bubbles.

Parameters

detailObject
What changed.
  • idstring
    The view's id.
  • openboolean
    Whether it is open now.
  • viewHTMLElement
    Its region: [data-riff-view="<id>"] for a screen of its own, [data-riff-panel="<id>"] for a panel, and Now Playing itself for the album or the turntable.
  • trackObject|null
    The track playing.
apiObject
window.riff.

More Information

Usage

wp.hooks.addAction( 'riff.view', 'my-plugin', ( detail, api ) => {
} );

// Or, without wp-hooks:
window.riff.on( 'view', ( detail ) => {} );

Source

emit( 'view', {
id,
open: isNowOpen,
view: v?.el || P.np,
track: P.track() || null,
} );

Changelog

VersionDescription
5.8.0Introduced.