SHARE
TWEET

Untitled

a guest Nov 19th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let mainWrap = document.querySelector('#mainWrap');
  2.  
  3. // element or group that have transform inline
  4. let gruopWithTransform = document.querySelector('#groupWithTransform');
  5. let rectWithTransform = document.querySelector('#rectWithTransform');
  6.  
  7. const groupWrap = (el) => {
  8.   let ghostGroup = document.createElement('g');
  9.  
  10.   if (el.nodeName == 'g') {
  11.     if (el.hasAttribute('id')) {
  12.       ghostGroup.id = el.id;
  13.       el.removeAttribute('id');
  14.     }
  15.   } else {
  16.     ghostGroup.setAttribute('transform', el.getAttribute('transform'));
  17.     el.removeAttribute('transform');
  18.   }
  19.  
  20.   if(el.nodeName === 'g') {
  21.     ghostGroup.classList.add('ghostGroupVisibleInLayers');
  22.     el.classList.add('ghostGroupInvisibleInLayers');
  23.   } else {
  24.     ghostGroup.classList.add('ghostGroupInvisibleInLayers');
  25.   }
  26.  
  27.   el.parentNode.insertBefore(ghostGroup, el);
  28.   ghostGroup.appendChild(el);
  29. }
  30.  
  31. groupWrap(gruopWithTransform);
  32. groupWrap(rectWithTransform);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top