From 449f6fbf7c058988ba6f18a8e70cba4bf6639941 Mon Sep 17 00:00:00 2001
From: nod_ <nod_@598310.no-reply.drupal.org>
Date: Thu, 18 Apr 2024 14:25:48 +0200
Subject: [PATCH] Issue #3239139 by shubh_, Theresa.Grannum, alexpott: Refactor
 (if feasible) uses of the jQuery animate function to use Vanilla/native

---
 core/.eslintrc.jquery.json             |  4 ++--
 core/misc/ajax.js                      |  6 +++++-
 core/modules/block/js/block.admin.js   | 18 +++++++-----------
 core/modules/ckeditor5/js/ckeditor5.js | 18 ++++++++++++------
 4 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/core/.eslintrc.jquery.json b/core/.eslintrc.jquery.json
index e53f784f2d77..e0317d173eaf 100644
--- a/core/.eslintrc.jquery.json
+++ b/core/.eslintrc.jquery.json
@@ -5,7 +5,7 @@
   "rules": {
     "jquery/no-ajax": 0,
     "jquery/no-ajax-events": 2,
-    "jquery/no-animate": 0,
+    "jquery/no-animate": 2,
     "jquery/no-attr": 0,
     "jquery/no-bind": 2,
     "jquery/no-class": 0,
@@ -53,4 +53,4 @@
     "jquery/no-when": 2,
     "jquery/no-wrap": 0
   }
-}
+}
\ No newline at end of file
diff --git a/core/misc/ajax.js b/core/misc/ajax.js
index 7483108f6b36..c476f204914c 100644
--- a/core/misc/ajax.js
+++ b/core/misc/ajax.js
@@ -1852,9 +1852,13 @@
       while ($(scrollTarget).scrollTop() === 0 && $(scrollTarget).parent()) {
         scrollTarget = $(scrollTarget).parent();
       }
+
       // Only scroll upward.
       if (offset.top - 10 < $(scrollTarget).scrollTop()) {
-        $(scrollTarget).animate({ scrollTop: offset.top - 10 }, 500);
+        scrollTarget.get(0).scrollTo({
+          top: offset.top - 10,
+          behavior: 'smooth',
+        });
       }
     },
   };
diff --git a/core/modules/block/js/block.admin.js b/core/modules/block/js/block.admin.js
index 055f2fccba56..fee71251f6b5 100644
--- a/core/modules/block/js/block.admin.js
+++ b/core/modules/block/js/block.admin.js
@@ -91,17 +91,13 @@
           context,
         ).forEach((container) => {
           const $container = $(container);
-          // Just scrolling the document.body will not work in Firefox. The html
-          // element is needed as well.
-          $('html, body').animate(
-            {
-              scrollTop:
-                $('.js-block-placed').offset().top -
-                $container.offset().top +
-                $container.scrollTop(),
-            },
-            500,
-          );
+          window.scrollTo({
+            top:
+              $('.js-block-placed').offset().top -
+              $container.offset().top +
+              $container.scrollTop(),
+            behavior: 'smooth',
+          });
         });
       }
     },
diff --git a/core/modules/ckeditor5/js/ckeditor5.js b/core/modules/ckeditor5/js/ckeditor5.js
index bd5f3facdf9c..7bace8702c0f 100644
--- a/core/modules/ckeditor5/js/ckeditor5.js
+++ b/core/modules/ckeditor5/js/ckeditor5.js
@@ -651,12 +651,18 @@
 
   // Respond to new dialogs that are opened by CKEditor, closing the AJAX loader.
   $(window).on('dialog:beforecreate', () => {
-    $('.ckeditor5-dialog-loading').animate(
-      { top: '-40px' },
-      function removeDialogLoading() {
-        $(this).remove();
-      },
-    );
+    const dialogLoading = document.querySelector('.ckeditor5-dialog-loading');
+
+    if (dialogLoading) {
+      dialogLoading.addEventListener(
+        'transitionend',
+        function removeDialogLoading() {
+          dialogLoading.remove();
+        },
+      );
+      dialogLoading.style.transition = 'top 0.5s ease';
+      dialogLoading.style.top = '-40px';
+    }
   });
 
   // Respond to dialogs that are saved, sending data back to CKEditor.
-- 
GitLab