Skip to content

Commit 3330405

Browse files
GambitGambit
authored andcommitted
add script for animation if block layout has hover
1 parent 92865ac commit 3330405

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/init.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,14 @@ function stackable_check_block_animation( $block_content, $block ) {
499499
return $block_content;
500500
}
501501

502+
$has_global_animations = apply_filters( 'stackable_has_global_animations', false );
503+
502504
if ( strpos( $block_content, ':hover' ) !== false || // Hover effects
503505
strpos( $block_content, '--entrance-' ) !== false || // Entrance animations
504506
strpos( $block_content, 'stk-anim' ) !== false || // Scroll animations
505507
strpos( $block_content, '--stk-tran' ) !== false || // Transition duration
506-
strpos( $block_content, 'stk-entrance' ) !== false // Entrance class
507-
508+
strpos( $block_content, 'stk-entrance' ) !== false || // Entrance class
509+
$has_global_animations !== false // Global block layouts has hover effects
508510
) {
509511
// Adds a special class to the body tag, to indicate we can now run animations.
510512
add_action( 'wp_footer', 'stackable_init_animations' );

src/plugins/global-settings/buttons-and-icons/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ public function add_global_buttons_and_icons_styles( $current_css ) {
101101
return $current_css;
102102
}
103103

104+
if ( strpos( $generated_css, 'hover' ) !== false ) {
105+
add_filter( 'stackable_has_global_animations', function( $has_global_animations ) {
106+
return true;
107+
} );
108+
}
109+
104110
$current_css .= $generated_css;
105111
return apply_filters( 'stackable_global_frontend_css' , $current_css );
106112
}

src/plugins/global-settings/spacing-and-borders/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ public function add_global_spacing_and_borders_styles( $current_css ) {
102102
return $current_css;
103103
}
104104

105+
if ( strpos( $generated_css, 'hover' ) !== false ) {
106+
add_filter( 'stackable_has_global_animations', function( $has_global_animations ) {
107+
return true;
108+
} );
109+
}
110+
105111
$current_css .= $generated_css;
106112
return apply_filters( 'stackable_global_frontend_css' , $current_css );
107113
}

0 commit comments

Comments
 (0)