diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-06-09 19:28:01 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-06-09 19:28:01 +0200 |
| commit | 149a75f80c5fbd09329a2e7f87204e67a2c429df (patch) | |
| tree | f601ef3e186b04640094fb3ca23ddd4498273025 /frontend/views/page/components/page.editor.js | |
| parent | 8a90618f30faa2955c395cc5d6c989259270a95b (diff) | |
add opacity slider and properly debounce it
Diffstat (limited to 'frontend/views/page/components/page.editor.js')
| -rw-r--r-- | frontend/views/page/components/page.editor.js | 100 |
1 files changed, 2 insertions, 98 deletions
diff --git a/frontend/views/page/components/page.editor.js b/frontend/views/page/components/page.editor.js index 37e23a7..297f7e7 100644 --- a/frontend/views/page/components/page.editor.js +++ b/frontend/views/page/components/page.editor.js @@ -11,6 +11,8 @@ import * as tileActions from '../../tile/tile.actions' import { Loader } from '../../../common' import { clamp, dist } from '../../../util' +import TileHandle from './tile.handle' + const defaultState = { dragging: false, bounds: null, @@ -196,104 +198,6 @@ class PageEditor extends Component { } } -const TileHandle = ({ tile, bounds, box, onMouseDown, onDoubleClick }) => { - // console.log(tile) - const { width, height } = tile.settings - const style = { - transform: generateTransform(tile, box), - } - // console.log(generateTransform(tile)) - let content; - let className = 'tile ' + tile.type - // console.log(tile.settings) - switch (tile.type) { - case 'image': - if (!tile.settings.url) { - return null - } - if (tile.settings.is_tiled) { - style.backgroundImage = 'url(' + tile.settings.url + ')' - style.backgroundPosition = tile.settings.align.replace('_', ' ') - switch (tile.settings.tile_style) { - default: - case 'tile': - break - case 'cover': - style.backgroundSize = 'cover' - break - case 'contain': - style.backgroundSize = 'contain' - break - case 'contain no-repeat': - style.backgroundSize = 'contain' - style.backgroundRepeat = 'no-repeat' - break - } - className += ' is_tiled' - } else { - className += ' ' + tile.settings.align - content = <img src={tile.settings.url} /> - } - break - case 'text': - if (!tile.settings.content) { - return null - } - 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.fontFamily = tile.settings.font_family - style.fontSize = tile.settings.font_size + 'px' - style.lineHeight = 1.5 - style.fontWeight = (tile.settings.font_style || "").indexOf('bold') !== -1 ? 'bold' : 'normal' - style.fontStyle = (tile.settings.font_style || "").indexOf('italic') !== -1 ? 'italic' : 'normal' - style.backgroundColor = tile.settings.background_color || 'transparent' - style.color = tile.settings.font_color || '#dddddd!important' - break - } - return ( - <div - className={className} - onMouseDown={onMouseDown} - onDoubleClick={onDoubleClick} - style={style} - > - {content} - </div> - ) -} - -const generateTransform = (tile, box) => { - let { x, y, align, rotation, scale, is_tiled } = tile.settings - if (is_tiled) { - return 'translateZ(0)' - } - if (box) { - x += box.dx - y += box.dy - } - const [yalign, xalign] = align.split('_') - let transform = ['translateZ(0)'] - if (yalign === 'center') { - transform.push('translateY(-50%)') - } - if (xalign === 'center') { - transform.push('translateX(-50%)') - } - // if (x % 2 == 1) x += 0.5 - // if (y % 2 == 1) y += 0.5 - transform.push('translateX(' + x + 'px)') - transform.push('translateY(' + y + 'px)') - if (scale !== 1) { - transform.push('scale(' + scale + ')') - } - if (rotation !== 0) { - transform.push('rotateZ(' + rotation + 'rad)') - } - return transform.join(' ') -} - const mapStateToProps = state => ({ graph: state.graph, page: state.page, |
