diff --git a/src/core/preview/preview.less b/src/core/preview/preview.less index 19c24a39..602f073c 100644 --- a/src/core/preview/preview.less +++ b/src/core/preview/preview.less @@ -1,31 +1,29 @@ .uip-preview { - display: flex; - align-items: flex-start; + display: block; + overflow: hidden; grid-area: preview; - &-inner { - flex: 1 0 auto; - height: 100%; + &-container { + display: flex; + justify-content: center; + align-items: center; + position: relative; + margin: auto; + overflow: hidden; + width: auto; + height: auto; max-width: 100%; max-height: 100%; - overflow: auto; - } - &[resizable] &-inner { - resize: both; + transition: min-height 0.5s linear; } - &-stub { - flex: 0 0 0; - width: 0; - transition: height 0.5s linear; + &[resizable] &-container { + resize: both; } - &.centered-content { - .uip-preview-inner { - display: flex; - justify-content: center; - align-items: center; - } + &-inner { + max-width: 100%; + max-height: 100%; } } diff --git a/src/core/preview/preview.tsx b/src/core/preview/preview.tsx index 5e292604..83051a56 100644 --- a/src/core/preview/preview.tsx +++ b/src/core/preview/preview.tsx @@ -1,6 +1,7 @@ import React from 'jsx-dom'; -import {bind, memoize} from '@exadel/esl/modules/esl-utils/decorators'; -import {afterNextRender, promisifyTransition} from '@exadel/esl/modules/esl-utils/async'; + +import {bind, listen, memoize} from '@exadel/esl/modules/esl-utils/decorators'; +import {afterNextRender, skipOneRender} from '@exadel/esl/modules/esl-utils/async'; import {UIPPlugin} from '../base/plugin'; @@ -12,37 +13,45 @@ export class UIPPreview extends UIPPlugin { static is = 'uip-preview'; static observedAttributes: string[] = ['dir', 'resizable']; - /** Extra element to animate decreasing height of content smoothly */ - @memoize() - protected get $stub(): HTMLElement { - const type = this.constructor as typeof UIPPreview; - return () as HTMLElement; - } - /** {@link UIPPlugin} section wrapper */ @memoize() protected get $inner(): HTMLElement { const pluginType = this.constructor as typeof UIPPlugin; - return
as HTMLElement; + return as HTMLElement; + } + + /** Extra element to animate decreasing height of content smoothly */ + @memoize() + protected get $container(): HTMLElement { + const type = this.constructor as typeof UIPPreview; + return ( +