summaryrefslogtreecommitdiff
path: root/frontend/app/views/page/components/tile.handle.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2021-03-16 14:43:00 +0100
committerJules Laplace <julescarbon@gmail.com>2021-03-16 14:43:00 +0100
commit6e18c6e4ef6344f92fed99dad9c83484487c32d7 (patch)
tree03bd8a0be46d4bc8ce1a0bf06cff5fbab5f9c8a0 /frontend/app/views/page/components/tile.handle.js
parent35a5ebebc2e3c3535cbef00fab08b5fe43bebe85 (diff)
add units to links
Diffstat (limited to 'frontend/app/views/page/components/tile.handle.js')
-rw-r--r--frontend/app/views/page/components/tile.handle.js23
1 files changed, 16 insertions, 7 deletions
diff --git a/frontend/app/views/page/components/tile.handle.js b/frontend/app/views/page/components/tile.handle.js
index 993acce..9331cb3 100644
--- a/frontend/app/views/page/components/tile.handle.js
+++ b/frontend/app/views/page/components/tile.handle.js
@@ -68,8 +68,8 @@ const TileHandle = ({ tile, bounds, box, viewing, onMouseDown, onDoubleClick })
}
content = <span dangerouslySetInnerHTML={{ __html: tile.settings.content }} />
className += ' ' + tile.settings.align
- style.width = tile.settings.width ? tile.settings.width + 'px' : 'auto'
- style.height = tile.settings.height ? tile.settings.height + 'px' : 'auto'
+ style.width = unitsDimension(tile, 'width')
+ style.height = unitsDimension(tile, 'height')
style.fontFamily = tile.settings.font_family
style.fontSize = tile.settings.font_size + 'px'
style.lineHeight = 1.5
@@ -82,8 +82,8 @@ const TileHandle = ({ tile, bounds, box, viewing, onMouseDown, onDoubleClick })
case 'link':
content = ""
className += ' ' + tile.settings.align
- style.width = tile.settings.width ? tile.settings.width + 'px' : 'auto'
- style.height = tile.settings.height ? tile.settings.height + 'px' : 'auto'
+ style.width = unitsDimension(tile, 'width')
+ style.height = unitsDimension(tile, 'height')
break
case 'script':
@@ -134,7 +134,7 @@ const TileHandle = ({ tile, bounds, box, viewing, onMouseDown, onDoubleClick })
}
const generateTransform = (tile, box) => {
- let { x, y, align, rotation, scale, is_tiled } = tile.settings
+ let { x, y, align, rotation, scale, units, is_tiled } = tile.settings
if (is_tiled) {
return 'translateZ(0)'
}
@@ -142,6 +142,7 @@ const generateTransform = (tile, box) => {
x += box.dx
y += box.dy
}
+ units = units || 'px'
const [yalign, xalign] = align.split('_')
let transform = ['translateZ(0)']
if (yalign === 'center') {
@@ -150,10 +151,11 @@ const generateTransform = (tile, box) => {
if (xalign === 'center') {
transform.push('translateX(-50%)')
}
+ console.log(units)
// if (x % 2 == 1) x += 0.5
// if (y % 2 == 1) y += 0.5
- transform.push('translateX(' + x + 'px)')
- transform.push('translateY(' + y + 'px)')
+ transform.push('translateX(' + x + units + ')')
+ transform.push('translateY(' + y + units + ')')
if (scale !== 1) {
transform.push('scale(' + scale + ')')
}
@@ -195,4 +197,11 @@ const generateVideoStyle = (tile, bounds) => {
return style
}
+const unitsDimension = (tile, dimension) => {
+ const value = tile.settings[dimension]
+ if (!value) return "auto"
+ if (tile.settings.units) return value + tile.settings.units
+ return value + "px"
+}
+
export default TileHandle