You are here

function animations_page_attachments in Animations (JS/CSS) 8

Implements hook_page_attachments(). Adds the library to every or selected pages.

File

./animations.module, line 48

Code

function animations_page_attachments(array &$page) {

  // attach the dynamic libraries and the main library to all pages
  $config = \Drupal::config('animations.config');
  foreach ($config
    ->get("animations_dependencies") as $key => $library) {
    $page['#attached']['library'][] = 'animations/animations.' . $key;
  }
  $page['#attached']['library'][] = 'animations/animations';

  // pass the configuration file to the js
  $config = \Drupal::config('animations.config');
  $page['#attached']['drupalSettings']['animations'] = $config
    ->get("animations");
}