Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Enqueue theme's main script.
- * Hook it in late to make sure any dependencies have been loaded.
- */
- function tower_child_enqueue_theme_script() {
- wp_enqueue_script('tower-child', get_stylesheet_directory_uri() . '/assets/js/theme.js', ['jquery'], false, true);
- $header_position = ( is_front_page() ) ? 'absolute' : 'relative';
- /**
- * STICKY HEADER ENFORCEMENT (BUG FIX)
- */
- $custom_js = "
- jQuery(document).ready(function () {
- 'use strict';
- //const header = jQuery('#header');
- const header_wrapper = jQuery('.header_wrapper');
- const body = jQuery(document.body);
- window.onscroll = function () {
- var top = window.scrollY;
- if (top >= 120) {
- body.addClass('sticky_header');
- header_wrapper.addClass('open');
- header_wrapper.css({'position': 'fixed', 'visibility': 'visible'});
- }
- else {
- body.removeClass('sticky_header');
- header_wrapper.removeClass('open');
- header_wrapper.css({'position': '{$header_position}', 'visibility': 'visible'});
- }
- }
- });
- ";
- wp_add_inline_script( 'tower-child', $custom_js );
- }
- add_action('wp_enqueue_scripts', 'tower_child_enqueue_theme_script', 100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement