@quartic/bokehjs
Version:
Interactive, novel data visualization
78 lines (67 loc) • 1.95 kB
text/coffeescript
import {GestureTool, GestureToolView} from "./gesture_tool"
import {show, hide} from "core/dom"
import * as p from "core/properties"
export class ResizeToolView extends GestureToolView
className: "bk-resize-popup"
initialize: (options) ->
super(options)
wrapper = .el.querySelector('div.bk-canvas-wrapper')
wrapper.appendChild()
hide()
= false
return null
activate: () ->
= true
return null
deactivate: () ->
= false
return null
render: (ctx) ->
if
canvas = .canvas
frame = .frame
left = canvas.vx_to_sx(frame.h_range.end-40)
top = canvas.vy_to_sy(frame.v_range.start+40)
.style.position = "absolute"
.style.top = "#{top}px"
.style.left = "#{left}px"
show()
else
hide()
return @
_pan_start: (e) ->
canvas = .canvas
= canvas.height
= canvas.width
.interactive_timestamp = Date.now()
return null
_pan: (e) ->
.interactive_timestamp = Date.now()
return null
_pan_end: (e) ->
.push_state("resize", {
dimensions: {
width: .canvas.width
height: .canvas.height
}
})
_update: (dx, dy) ->
new_width = + dx
new_height = + dy
if new_width < 100 or new_height < 100
# TODO (bird) This should probably be more intelligent, so that resize can
# go as small as possible without breaking, but 100 x 100 seems reasonable
# as a hardcoded value for now.
return
.update_dimensions(new_width, new_height)
return
export class ResizeTool extends GestureTool
default_view: ResizeToolView
type: "ResizeTool"
tool_name: "Resize"
icon: "bk-tool-icon-resize"
event_type: "pan"
default_order: 40