Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. 'use strict';
  2. (function(){
  3.  
  4. var data = 0
  5.  
  6. window.renderPin = function (array) {
  7. data = array
  8. var PIN_IMG_SIZE = 40;
  9. var PIN_WIDTH = 56;
  10. var PIN_HEIGHT = 75;
  11. var fragmentTag = document.createDocumentFragment();
  12. var tokyoPinMap = document.querySelector('.tokyo__pin-map');
  13.  
  14. for (var i = 0; i < array.length; i++) {
  15. var blockTag = document.createElement('div');
  16. var img = document.createElement('img');
  17. blockTag.className = 'pin';
  18. blockTag.setAttribute('style', 'left:' + (array[i].location.x - (Math.ceil(PIN_WIDTH) / 2))
  19. + 'px;top:' + (array[i].location.y - Math.ceil(PIN_HEIGHT)) + 'px');
  20. blockTag.setAttribute('id', 'pin-id-' + (i + 1));
  21. blockTag.setAttribute('data-pincount', (i + 1));
  22. blockTag.setAttribute('tabindex', 0);
  23. img.className = 'rounded';
  24. img.setAttribute('src', array[i].author.avatar);
  25. img.setAttribute('width', PIN_IMG_SIZE);
  26. img.setAttribute('height', PIN_IMG_SIZE);
  27. blockTag.appendChild(img);
  28. fragmentTag.appendChild(blockTag);
  29. }
  30.  
  31. tokyoPinMap.appendChild(fragmentTag);
  32.  
  33. return{
  34. data: 3
  35. }
  36.  
  37. }
  38.  
  39. })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement