fix: restore proper spinning animation for mobile refresh FAB
Reverted HTML replacement approach and restored the cleaner CSS-based animation from commit1855085. Previous (wrong) approach: - Replaced button HTML with spinner - Modified both desktop and mobile buttons in apiClient.js - Messy and inconsistent Restored (correct) approach: - Add/remove .spinning CSS class in click handler - CSS animates only the icon inside the button - Button itself stays unchanged - Much cleaner implementation Changes: - Reverted apiClient.js changes from commit9a49433- Added .spinning CSS class and @keyframes rpg-spin - Updated index.js click handler to bind both buttons - Uses addClass/removeClass for clean animation control - Includes drag detection to prevent accidental clicks Now the mobile FAB icon spins smoothly when refreshing!
This commit is contained in:
@@ -328,12 +328,34 @@ async function initUI() {
|
|||||||
toggleAnimations();
|
toggleAnimations();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#rpg-manual-update').on('click', async function() {
|
// Bind to both desktop and mobile refresh buttons
|
||||||
|
$('#rpg-manual-update, #rpg-manual-update-mobile').on('click', async function() {
|
||||||
|
// Get mobile button reference
|
||||||
|
const $mobileBtn = $('#rpg-manual-update-mobile');
|
||||||
|
|
||||||
|
// Skip if we just finished dragging the mobile button
|
||||||
|
if ($mobileBtn.data('just-dragged')) {
|
||||||
|
console.log('[RPG Companion] Click blocked - just finished dragging refresh button');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!extensionSettings.enabled) {
|
if (!extensionSettings.enabled) {
|
||||||
// console.log('[RPG Companion] Extension is disabled. Please enable it in the Extensions tab.');
|
// console.log('[RPG Companion] Extension is disabled. Please enable it in the Extensions tab.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await updateRPGData(renderUserStats, renderInfoBox, renderThoughts, renderInventory);
|
|
||||||
|
// Remove focus to prevent sticky black state on mobile
|
||||||
|
$(this).blur();
|
||||||
|
|
||||||
|
// Add spinning animation to mobile button
|
||||||
|
$mobileBtn.addClass('spinning');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await updateRPGData(renderUserStats, renderInfoBox, renderThoughts, renderInventory);
|
||||||
|
} finally {
|
||||||
|
// Remove spinning animation when done
|
||||||
|
$mobileBtn.removeClass('spinning');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reset FAB positions button
|
// Reset FAB positions button
|
||||||
|
|||||||
@@ -97,16 +97,11 @@ export async function updateRPGData(renderUserStats, renderInfoBox, renderThough
|
|||||||
try {
|
try {
|
||||||
setIsGenerating(true);
|
setIsGenerating(true);
|
||||||
|
|
||||||
// Update desktop button to show "Updating..." state
|
// Update button to show "Updating..." state
|
||||||
const $updateBtn = $('#rpg-manual-update');
|
const $updateBtn = $('#rpg-manual-update');
|
||||||
const originalHtml = $updateBtn.html();
|
const originalHtml = $updateBtn.html();
|
||||||
$updateBtn.html('<i class="fa-solid fa-spinner fa-spin"></i> Updating...').prop('disabled', true);
|
$updateBtn.html('<i class="fa-solid fa-spinner fa-spin"></i> Updating...').prop('disabled', true);
|
||||||
|
|
||||||
// Update mobile FAB to show spinner (icon only)
|
|
||||||
const $updateBtnMobile = $('#rpg-manual-update-mobile');
|
|
||||||
const originalHtmlMobile = $updateBtnMobile.html();
|
|
||||||
$updateBtnMobile.html('<i class="fa-solid fa-spinner fa-spin"></i>').prop('disabled', true);
|
|
||||||
|
|
||||||
// Save current preset name before switching (if we're going to switch)
|
// Save current preset name before switching (if we're going to switch)
|
||||||
if (extensionSettings.useSeparatePreset) {
|
if (extensionSettings.useSeparatePreset) {
|
||||||
originalPresetName = await getCurrentPresetName();
|
originalPresetName = await getCurrentPresetName();
|
||||||
@@ -224,14 +219,10 @@ export async function updateRPGData(renderUserStats, renderInfoBox, renderThough
|
|||||||
|
|
||||||
setIsGenerating(false);
|
setIsGenerating(false);
|
||||||
|
|
||||||
// Restore desktop button to original state
|
// Restore button to original state
|
||||||
const $updateBtn = $('#rpg-manual-update');
|
const $updateBtn = $('#rpg-manual-update');
|
||||||
$updateBtn.html('<i class="fa-solid fa-sync"></i> Refresh RPG Info').prop('disabled', false);
|
$updateBtn.html('<i class="fa-solid fa-sync"></i> Refresh RPG Info').prop('disabled', false);
|
||||||
|
|
||||||
// Restore mobile FAB to original state (icon only)
|
|
||||||
const $updateBtnMobile = $('#rpg-manual-update-mobile');
|
|
||||||
$updateBtnMobile.html('<i class="fa-solid fa-sync"></i>').prop('disabled', false);
|
|
||||||
|
|
||||||
// Reset the flag after tracker generation completes
|
// Reset the flag after tracker generation completes
|
||||||
// This ensures the flag persists through both main generation AND tracker generation
|
// This ensures the flag persists through both main generation AND tracker generation
|
||||||
// console.log('[RPG Companion] 🔄 Tracker generation complete - resetting lastActionWasSwipe to false');
|
// console.log('[RPG Companion] 🔄 Tracker generation complete - resetting lastActionWasSwipe to false');
|
||||||
|
|||||||
@@ -3344,6 +3344,24 @@ body:has(.rpg-panel.rpg-position-left) #sheld {
|
|||||||
transform: scale(0.95);
|
transform: scale(0.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Spinning animation when refreshing */
|
||||||
|
.rpg-mobile-refresh.spinning i {
|
||||||
|
animation: rpg-spin 0.8s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rpg-mobile-refresh i {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes rpg-spin {
|
||||||
|
from {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Mobile overlay backdrop */
|
/* Mobile overlay backdrop */
|
||||||
.rpg-mobile-overlay {
|
.rpg-mobile-overlay {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
Reference in New Issue
Block a user