Skip to content

Commit

Permalink
fix image positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
makamekm committed Mar 4, 2020
1 parent 9d8754f commit cc45936
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions style.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,23 +279,21 @@ async function setFrameStyles(state, shared) {
if (images[node.id] != null && !Object.keys(props).includes('gbg')) {
const url = `url(${await loadImageFromImagesToDisk(node, shared)})`;

if (bounds && Math.abs(bounds.angle) > 0) {
const left = (parent.absoluteBoundingBox.width - bounds.width) / 2 / bounds.width;
const top = (parent.absoluteBoundingBox.height - bounds.height) / 2 / bounds.height;
if (bounds && Math.abs(bounds.angle)) {
middleStyle.display = 'flex';
middleStyle.justifyContent = 'center';
middleStyle.alignItems = 'center';

const afterId = genClassName();
classNames.push(afterId);
additionalStyles.push(`
.${afterId}::after {
position: absolute;
pointer-events: none;
left: -${left * 100}%;
right: -${left * 100}%;
top: -${top * 100}%;
bottom: -${top * 100}%;
width: ${node.absoluteBoundingBox.width / bounds.width * 100}%;
height: ${node.absoluteBoundingBox.height / bounds.height * 100}%;
content: '';
background: ${url} center center no-repeat;
background-size: contain;
background-size: cover;
transform: rotate(${bounds.angle}deg);
transform-origin: 50% 50%;
}
Expand Down

0 comments on commit cc45936

Please sign in to comment.