Advertisement
Guest User

mapTest 2

a guest
Dec 23rd, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. # This imports all the layers for "zoom" into zoomLayers
  2. zoom = Framer.Importer.load "imported/zoom"
  3.  
  4. map = zoom.map
  5. nav = zoom.nav
  6. footer = zoom.footer
  7. zoomIn = zoom.zoomIn
  8. zoomOut = zoom.zoomOut
  9.  
  10. # variables
  11. mapScale = 1
  12. scaleInterval = 0.2
  13.  
  14. # bar properties
  15. nav.opacity = 0.5
  16. footer.opacity = 0.5
  17. # map properties
  18. map.draggable.enabled = true
  19. originalMapWidth = map.width
  20. originalMapHeight = map.height
  21.  
  22.  
  23.  
  24.  
  25. scaleContent = (element, scaleAmount) ->
  26.  
  27. newWidth = map.width * (scaleAmount/1)
  28. newHeight = map.height * (scaleAmount/1)
  29. differenceWidth = newWidth / originalMapWidth
  30. differenceHeight = newHeight / originalMapHeight
  31.  
  32. # I need to fix these two values below!!
  33. mapXPos = map.x
  34. mapYPos = map.y
  35.  
  36. print "scale: " + Utils.round(mapScale, 1)
  37. print "X Pos: " + mapXPos + "Y Pos: " + mapYPos
  38.  
  39. # Middle screen (desired origin point)
  40. displayMidY = (Framer.Device.screen.height)/2 # height of device window
  41. displayMidX = (Framer.Device.screen.width)/2 # height of device window
  42.  
  43. # this finds the exact spot for the scale origin of the layer
  44. scaleOriginX = mapXPos - displayMidX
  45. scaleOriginY = mapYPos - displayMidY
  46.  
  47. # These are used to place red dots
  48. scaleOriginXfull = -(scaleOriginX)
  49. scaleOriginYfull = -(scaleOriginY)
  50.  
  51. #transforms value to a number between 0-1
  52. scaleOriginX = Utils.modulate(scaleOriginX, [0, -(newWidth)], [0, 1])
  53. scaleOriginY = Utils.modulate(scaleOriginY, [0, -(newHeight)], [0, 1])
  54.  
  55. element.originX = scaleOriginX
  56. element.originY = scaleOriginY
  57.  
  58. originPoint = new Layer ({
  59. height: 20
  60. width: 20
  61. borderRadius: 10
  62. opacity: 0.6
  63. backgroundColor: "red"
  64. x: scaleOriginXfull
  65. y: scaleOriginYfull
  66. })
  67.  
  68. element.animate({
  69. properties: {scale:scaleAmount},
  70. curve: "ease-in-out",
  71. time:0.5
  72. })
  73.  
  74. zoomIn.on Events.Click, ->
  75. mapScale += scaleInterval
  76. scaleContent(map, mapScale)
  77.  
  78.  
  79. zoomOut.on Events.Click, ->
  80. mapScale -= scaleInterval
  81. scaleContent(map, mapScale)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement