Ticket #59689: 59689.6.diff
| File 59689.6.diff, 2.5 KB (added by , 2 years ago) |
|---|
-
src/js/_enqueues/admin/common.js
2129 2129 /** 2130 2130 * Freeze animated plugin icons when reduced motion is enabled. 2131 2131 * 2132 * When the user has enabled the 'prefers-reduced-motion' setting, this module 2133 * stops animations for all GIFs on the page with the class 'plugin-icon' or 2132 * When the user has enabled the 'prefers-reduced-motion' setting, this module 2133 * stops animations for all GIFs on the page with the class 'plugin-icon' or 2134 2134 * plugin icon images in the update plugins table. 2135 2135 * 2136 2136 * @since 6.4.0 … … 2156 2156 var width = img.width; 2157 2157 var height = img.height; 2158 2158 var canvas = document.createElement( 'canvas' ); 2159 2159 2160 2160 // Set canvas dimensions. 2161 2161 canvas.width = width; 2162 2162 canvas.height = height; … … 2219 2219 2220 2220 // Listen for jQuery AJAX events. 2221 2221 ( function( $ ) { 2222 $( document ).ajaxComplete( function( event, xhr, settings ) { 2223 // Check if this is the 'search-install-plugins' request. 2224 if ( settings.data && settings.data.includes( 'action=search-install-plugins' ) ) { 2225 // Recheck if the user prefers reduced motion. 2226 if ( window.matchMedia ) { 2227 var mediaQuery = window.matchMedia( '(prefers-reduced-motion: reduce)' ); 2228 if ( mediaQuery.matches ) { 2229 pub.freezeAll(); 2222 if ( window.pagenow === 'plugin-install' ) { 2223 // Only listen for ajaxComplete if this is the plugin-install.php page. 2224 $( document ).ajaxComplete( function( event, xhr, settings ) { 2225 2226 // Check if this is the 'search-install-plugins' request. 2227 if ( settings.data && typeof settings.data === 'string' && settings.data.includes( 'action=search-install-plugins' ) ) { 2228 // Recheck if the user prefers reduced motion. 2229 if ( window.matchMedia ) { 2230 var mediaQuery = window.matchMedia( '(prefers-reduced-motion: reduce)' ); 2231 if ( mediaQuery.matches ) { 2232 pub.freezeAll(); 2233 } 2234 } else { 2235 // Fallback for browsers that don't support matchMedia. 2236 if ( true === priv.pauseAll ) { 2237 pub.freezeAll(); 2238 } 2230 2239 } 2231 } else {2232 // Fallback for browsers that don't support matchMedia.2233 if ( true === priv.pauseAll ) {2234 pub.freezeAll();2235 }2236 2240 } 2237 } 2238 } );2241 } ); 2242 } 2239 2243 } )( jQuery ); 2240 2244 2241 2245 // Expose public methods.