Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This imports all the layers for "zoom" into zoomLayers
- zoom = Framer.Importer.load "imported/zoom"
- map = zoom.map
- nav = zoom.nav
- footer = zoom.footer
- zoomIn = zoom.zoomIn
- zoomOut = zoom.zoomOut
- # variables
- mapScale = 1
- scaleInterval = 0.2
- # bar properties
- nav.opacity = 0.5
- footer.opacity = 0.5
- # map properties
- map.draggable.enabled = true
- originalMapWidth = map.width
- originalMapHeight = map.height
- scaleContent = (element, scaleAmount) ->
- newWidth = map.width * (scaleAmount/1)
- newHeight = map.height * (scaleAmount/1)
- differenceWidth = newWidth / originalMapWidth
- differenceHeight = newHeight / originalMapHeight
- # I need to fix these two values below!!
- mapXPos = map.x
- mapYPos = map.y
- print "scale: " + Utils.round(mapScale, 1)
- print "X Pos: " + mapXPos + "Y Pos: " + mapYPos
- # Middle screen (desired origin point)
- displayMidY = (Framer.Device.screen.height)/2 # height of device window
- displayMidX = (Framer.Device.screen.width)/2 # height of device window
- # this finds the exact spot for the scale origin of the layer
- scaleOriginX = mapXPos - displayMidX
- scaleOriginY = mapYPos - displayMidY
- # These are used to place red dots
- scaleOriginXfull = -(scaleOriginX)
- scaleOriginYfull = -(scaleOriginY)
- #transforms value to a number between 0-1
- scaleOriginX = Utils.modulate(scaleOriginX, [0, -(newWidth)], [0, 1])
- scaleOriginY = Utils.modulate(scaleOriginY, [0, -(newHeight)], [0, 1])
- element.originX = scaleOriginX
- element.originY = scaleOriginY
- originPoint = new Layer ({
- height: 20
- width: 20
- borderRadius: 10
- opacity: 0.6
- backgroundColor: "red"
- x: scaleOriginXfull
- y: scaleOriginYfull
- })
- element.animate({
- properties: {scale:scaleAmount},
- curve: "ease-in-out",
- time:0.5
- })
- zoomIn.on Events.Click, ->
- mapScale += scaleInterval
- scaleContent(map, mapScale)
- zoomOut.on Events.Click, ->
- mapScale -= scaleInterval
- scaleContent(map, mapScale)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement