🔍 calculating minZoom based on terminal width, fit map on startup

pull/7/head
Michael Straßburger 2016-10-03 16:42:14 +02:00
rodzic dd755ba8a8
commit 043e271985
1 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -37,6 +37,8 @@ module.exports = class Termap
zoom: 0
view: [0, 0]
minZoom: null
constructor: (options) ->
@config[key] = val for key, val of options
@ -69,12 +71,14 @@ module.exports = class Termap
@_draw()
@_resizeRenderer()
@zoom = 4-Math.log(4096/@width)/Math.LN2
@zoom = @minZoom
_resizeRenderer: (cb) ->
@width = @config.output.columns >> 1 << 2
@height = @config.output.rows * 4 - 4
@minZoom = 4-Math.log(4096/@width)/Math.LN2
@renderer.setSize @width, @height
_onClick: (event) ->
@ -168,7 +172,7 @@ module.exports = class Termap
#features.map((f) -> JSON.stringify f.feature.properties).join(" - ")
zoomBy: (step) ->
return @zoom = 0 if @zoom+step < 0
return @zoom = @minZoom if @zoom+step < @minZoom
before = @zoom
@zoom += step