Skip to content

Commit

Permalink
Fix preview position
Browse files Browse the repository at this point in the history
[Issue] Samsung#319

[Problem] Preview element is moved outside of screen

[Cause] transform: translate(-50%, -50%) is not removed from
        closet-preview-container. This happens because
        getBoundingClientRect on closet-design-editor-frame
        returns 0 since its visibility is set to hidden for
        remote samples in order not to show design editor
        and go to preview directly.

[Solution] Remove transform: translate(-50%, -50%).

[Test]
    1. Go to the page http://localhost:3000/demos?path=1.0%2Fexamples%2Fmobile%2FUIComponents%2Fcomponents%2Fnavigationelements%2Fpanel%2Findex.html
    2. Open the preview.
    3. Preview should be placed in the centre of screen.

Signed-off-by: Grzegorz Czajkowski <g.czajkowski@samsung.com>
  • Loading branch information
grzegorz-czajkowski committed Sep 11, 2019
1 parent 072ec87 commit 890c85c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions design-editor/src/panel/preview/preview-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class Preview extends DressElement {
*/
show({editor, callback}) {
const $targetFrame = editor && editor.getDesignViewIframe(),
// FIXME: $targetFrame is hidden for TAU remote samples and its position is 0.
position = ($targetFrame && $targetFrame[0].getBoundingClientRect()) || {top: 0, left: 0};

if ($targetFrame && editor) {
Expand Down Expand Up @@ -125,13 +126,12 @@ class Preview extends DressElement {
styles = {
width: `${screenConfig.width}px`,
height: `${screenConfig.height}px`,
transform: `scale(${ratio}) translate(-50% -50%)`
transform: `scale(${ratio})`
};

if (position.top) {
styles.top = position.top;
styles.left = position.left;
styles.transform = `scale(${ratio})`;
}

$elem.addClass(`closet-preview-shape-${screenConfig.shape}`)
Expand Down
1 change: 0 additions & 1 deletion design-editor/styles/design-editor/preview.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ closet-preview-element {
top: 50%;
left: 50%;
opacity: 0;
transform: translate(-50%, -50%);
transform-origin: top left;
transition-property: opacity;
transition-duration: 300ms;
Expand Down

0 comments on commit 890c85c

Please sign in to comment.