daily pastebin goal
44%
SHARE
TWEET

Untitled

RedWz Jul 19th, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var v = getVisual();
  2.  
  3. var fieldLeft = gamefield.getBoundingClientRect().x;
  4. var fieldTop = gamefield.getBoundingClientRect().y;
  5. var fieldCenterX = gamefield.getBoundingClientRect().width / 2;
  6. var fieldCenterY = gamefield.getBoundingClientRect().height / 2;
  7.  
  8. var currentDomino = getDomino(2,5);
  9.  
  10. moveTo(currentDomino, fieldCenterX, fieldCenterY);
  11.  
  12. // moveTo(v, 500, 500);
  13.  
  14.  
  15.  
  16.  
  17.  
  18. function getDomino(topValue, bottomValue) {
  19.     let result = 0;
  20.     topValue = topValue.toString();
  21.     bottomValue = bottomValue.toString();
  22.     document.querySelectorAll('.domino').forEach(el => {
  23.         if (el.dataset.dominoValueTop === topValue
  24.                 && el.dataset.dominoValueBottom === bottomValue) {
  25.             result = el;
  26.         }
  27.     });
  28.     return result;
  29. }
  30.  
  31. function moveTo(el, x, y) {
  32.     if (el) {
  33.         el.classList.remove('animatetohand');
  34.         gamefield.append(el);
  35.         el.classList.add('absolute');
  36.         el.classList.add('vertical');
  37.         el.style.transform = `translate(calc(${x}px - 50%), calc(${y}px - 50%))`;
  38.     }
  39. }
  40.  
  41. function getVisual() {
  42.     if (!document.querySelector('#tmpposition')) {
  43.         var tmp = document.createElement('div');
  44.         tmp.id = '#tmpposition';
  45.         tmp.style.position = 'absolute';
  46.         tmp.style.top = '0';
  47.         tmp.style.left = '0';
  48.         tmp.style.color = 'red';
  49.         tmp.style.transition = '1s';
  50.         tmp.innerHTML = `H`;
  51.         document.body.append(tmp);
  52.         return tmp;
  53.     } else {
  54.         return document.querySelector('#tmpposition');
  55.     }
  56. }
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