diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2021-04-01 17:30:37 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2021-04-01 17:30:37 +0200 |
| commit | 7e344419330855dbbf10896c39e91b4e6861dd57 (patch) | |
| tree | a8baae6cb875a3e8dad47bc4d8392738445f00fd /frontend/app/views/tile/tile.utils.js | |
| parent | 5cafa9d43b769e6f60740f59293ddf3588e7b8ad (diff) | |
displaying custom cursors on the frontend
Diffstat (limited to 'frontend/app/views/tile/tile.utils.js')
| -rw-r--r-- | frontend/app/views/tile/tile.utils.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/frontend/app/views/tile/tile.utils.js b/frontend/app/views/tile/tile.utils.js index 043732b..b946716 100644 --- a/frontend/app/views/tile/tile.utils.js +++ b/frontend/app/views/tile/tile.utils.js @@ -103,4 +103,24 @@ export const hexToRgb = (hex) => { g: parseInt(result[2], 16), b: parseInt(result[3], 16) } : null +} + +export const pickCursor = (tile, cursors, viewing) => { + const { cursor, custom_cursor_id } = tile.settings + const isCustom = cursor === 'custom' && custom_cursor_id in cursors + const customCursor = isCustom ? cursors[custom_cursor_id] : null + const x = isCustom ? Math.round(customCursor.settings.width / 2) : null + const y = isCustom ? Math.round(customCursor.settings.height / 2) : null + let className, cursorStyle + if (tile.target_page_id || (viewing && tile.href)) { + if ((viewing || cursor !== 'unclickable') && !isCustom) { + className = (tile.settings.cursor || 'hand_up') + } + } + if (isCustom) { + className = null + cursorStyle = `url(${customCursor.url}) ${x} ${y}, ` + cursorStyle += (tile.target_page_id || tile.href) ? 'pointer' : 'default' + } + return [className, cursorStyle] }
\ No newline at end of file |
