summaryrefslogtreecommitdiff
path: root/frontend/app/views/tile/tile.utils.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2021-03-22 16:06:13 +0100
committerJules Laplace <julescarbon@gmail.com>2021-03-22 16:06:13 +0100
commit285bc89a400c2faa7b6c7c327300c7842711935b (patch)
tree5d6d3c6e2f6b844a5cd4ef980c8c3237a806dabe /frontend/app/views/tile/tile.utils.js
parent30265efd64167e9fd6b5a489bd7f8239b496ed35 (diff)
fix proportional sizing
Diffstat (limited to 'frontend/app/views/tile/tile.utils.js')
-rw-r--r--frontend/app/views/tile/tile.utils.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/frontend/app/views/tile/tile.utils.js b/frontend/app/views/tile/tile.utils.js
index ed1cbc8..46d7764 100644
--- a/frontend/app/views/tile/tile.utils.js
+++ b/frontend/app/views/tile/tile.utils.js
@@ -1,4 +1,4 @@
-export const generateTransform = (tile, box, videoBounds) => {
+export const generateTransform = (tile, box, bounds, videoBounds) => {
let { x, y, align, rotation, scale, units, is_tiled } = tile.settings
if (is_tiled) {
return 'translateZ(0)'
@@ -18,8 +18,8 @@ export const generateTransform = (tile, box, videoBounds) => {
}
// if (x % 2 == 1) x += 0.5
// if (y % 2 == 1) y += 0.5
- const xUnits = units === 'video' ? videoUnits(x, videoBounds) : x + units
- const yUnits = units === 'video' ? videoUnits(y, videoBounds) : y + units
+ const xUnits = units === 'video' ? videoUnits(x, bounds, videoBounds) : x + units
+ const yUnits = units === 'video' ? videoUnits(y, bounds, videoBounds) : y + units
transform.push('translateX(' + xUnits + ')')
transform.push('translateY(' + yUnits + ')')
@@ -63,18 +63,18 @@ export const generateVideoStyle = (tile, bounds) => {
return style
}
-export const unitsDimension = (tile, dimension, videoBounds) => {
+export const unitsDimension = (tile, dimension, bounds, videoBounds) => {
const value = tile.settings[dimension]
if (!value) return "auto"
if (tile.settings.units) {
if (tile.settings.units === 'video') {
- return videoUnits(value, videoBounds)
+ return videoUnits(value, bounds, videoBounds)
}
return value + tile.settings.units
}
return value + "px"
}
-export const videoUnits = (value, videoBounds) => (
- (value / 1000 * Math.max(videoBounds.width, videoBounds.height)) + 'px'
+export const videoUnits = (value, bounds, videoBounds) => (
+ Math.round(value / videoBounds.width * bounds.width) + 'px'
) \ No newline at end of file