Advertisement
kopyl

Untitled

Aug 18th, 2021
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. const revertResize = (currentlySelectedLayers) => {
  3.     for (let x=0; x<currentlySelectedLayers.length; x++) {
  4.         let currentlySelectedLayerWidth = currentlySelectedLayers[x].width
  5.         let currentlySelectedLayerHeight = currentlySelectedLayers[x].height
  6.         currentlySelectedLayers[x].resize(currentlySelectedLayerWidth+1, currentlySelectedLayerHeight)
  7.     }
  8.    
  9. }
  10.  
  11. const collapseParentOf = (currentlySelectedLayer) => {
  12.     let parent = currentlySelectedLayer.parent
  13.     figma.currentPage.selection = [parent]
  14.     parent.expanded = false
  15. }
  16.  
  17. const collapseCurrentLayer = () => {
  18.     let currentlySelectedLayer = figma.currentPage.selection[0]
  19.     currentlySelectedLayer.expanded = false
  20. }
  21.  
  22. const selectFirstLayerInGroup = () => {
  23.     let nodeToSelect = figma.currentPage.selection[0].children.slice(-1)[0] // last
  24.     figma.currentPage.selection = [nodeToSelect]
  25.     nodeToSelect.expanded = false
  26. }
  27.  
  28. document.addEventListener('keydown', function(event) {
  29.   if (event.ctrlKey && event.key === 'ArrowLeft') {
  30.     let currentlySelectedLayers = figma.currentPage.selection
  31.     revertResize(currentlySelectedLayers)
  32.     collapseParentOf(currentlySelectedLayers[0])
  33.   }
  34. });
  35.  
  36. document.addEventListener('keydown', function(event) {
  37.   if (event.shiftKey && event.key === 'C') {
  38.     collapseCurrentLayer()
  39.   }
  40. });
  41.  
  42.  
  43. document.addEventListener('keydown', function(event) {
  44.   if (event.ctrlKey && event.key === 'Enter') {
  45.     selectFirstLayerInGroup()
  46.   }
  47. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement