]> cat aescling's git repositories - mastodon.git/commitdiff
Use LoadingBar instead of blur to indicate that an image is loading (fixes #4060...
authorThibG <thib@sitedethib.com>
Sat, 14 Jul 2018 23:18:09 +0000 (01:18 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Sat, 14 Jul 2018 23:18:09 +0000 (01:18 +0200)
app/javascript/mastodon/features/ui/components/image_loader.js
app/javascript/styles/mastodon/components.scss

index c7360a7264755a07ce95d73a5bb47289eee2de5c..5e1cf75af79aad303c4a5be2edcd239c97b77de5 100644 (file)
@@ -1,6 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
 import classNames from 'classnames';
+import { LoadingBar } from 'react-redux-loading-bar';
 import ZoomableImage from './zoomable_image';
 
 export default class ImageLoader extends React.PureComponent {
@@ -23,6 +24,7 @@ export default class ImageLoader extends React.PureComponent {
   state = {
     loading: true,
     error: false,
+    width: null,
   }
 
   removers = [];
@@ -122,6 +124,7 @@ export default class ImageLoader extends React.PureComponent {
 
   setCanvasRef = c => {
     this.canvas = c;
+    if (c) this.setState({ width: c.offsetWidth });
   }
 
   render () {
@@ -135,6 +138,7 @@ export default class ImageLoader extends React.PureComponent {
 
     return (
       <div className={className}>
+        <LoadingBar loading={loading ? 1 : 0} className='loading-bar' style={{ width: this.state.width || width }} />
         {loading ? (
           <canvas
             className='image-loader__preview-canvas'
index 5fa73d58a207d54485432c075c2c0a03956ed0da..b3d8f135f817088e0a1dea9c3f32f2d5548515e0 100644 (file)
@@ -1478,6 +1478,7 @@ a.account__display-name {
   display: flex;
   align-items: center;
   justify-content: center;
+  flex-direction: column;
 
   .image-loader__preview-canvas {
     max-width: $media-modal-media-max-width;
@@ -1486,8 +1487,8 @@ a.account__display-name {
     object-fit: contain;
   }
 
-  &.image-loader--loading .image-loader__preview-canvas {
-    filter: blur(2px);
+  .loading-bar {
+    position: relative;
   }
 
   &.image-loader--amorphous .image-loader__preview-canvas {