kopia lustrzana https://github.com/rastapasta/mapscii
🔍 calculating minZoom based on terminal width, fit map on startup
rodzic
dd755ba8a8
commit
043e271985
|
@ -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
|
||||
|
|
Ładowanie…
Reference in New Issue