Fix accordion animation and icon rotation with simplified state management
This commit is contained in:
@ -742,24 +742,21 @@ function wp_allstars_settings_page() {
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
jQuery(document).ready(function($) {
|
jQuery(document).ready(function($) {
|
||||||
|
// Handle accordion functionality
|
||||||
$('.wp-allstars-expand-settings').on('click', function(e) {
|
$('.wp-allstars-expand-settings').on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
|
||||||
|
|
||||||
var $button = $(this);
|
var $button = $(this);
|
||||||
var $panel = $button.closest('.wp-allstars-toggle').find('.wp-allstars-toggle-settings');
|
var $panel = $button.closest('.wp-allstars-toggle').find('.wp-allstars-toggle-settings');
|
||||||
var $icon = $button.find('.dashicons');
|
var $icon = $button.find('.dashicons');
|
||||||
|
|
||||||
|
// Toggle panel
|
||||||
|
$panel.slideToggle(200, function() {
|
||||||
|
// Update state after animation completes
|
||||||
var isExpanded = $panel.is(':visible');
|
var isExpanded = $panel.is(':visible');
|
||||||
|
$button.attr('aria-expanded', isExpanded);
|
||||||
// Toggle panel with animation
|
$icon.toggleClass('is-expanded', isExpanded);
|
||||||
$panel.slideToggle(200);
|
});
|
||||||
|
|
||||||
// Update button state
|
|
||||||
$button.attr('aria-expanded', !isExpanded);
|
|
||||||
|
|
||||||
// Update icon
|
|
||||||
$icon.toggleClass('dashicons-arrow-down-alt2', isExpanded)
|
|
||||||
.toggleClass('dashicons-arrow-up-alt2', !isExpanded);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -828,6 +825,10 @@ function wp_allstars_settings_page() {
|
|||||||
transition: transform 0.2s ease;
|
transition: transform 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wp-allstars-expand-settings .dashicons.is-expanded {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
.wp-allstars-toggle-settings {
|
.wp-allstars-toggle-settings {
|
||||||
border-top: 1px solid #ccd0d4;
|
border-top: 1px solid #ccd0d4;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
|
Reference in New Issue
Block a user