coffeescript-ui
Version:
Coffeescript User Interface System
69 lines (55 loc) • 1.97 kB
text/coffeescript
###
* coffeescript-ui - Coffeescript User Interface System (CUI)
* Copyright (c) 2013 - 2016 Programmfabrik GmbH
* MIT Licence
* https://github.com/programmfabrik/coffeescript-ui, http://www.coffeescript-ui.org
###
class CUI.Resizable extends CUI.Movable
= "resizable"
initOpts: ->
super()
readOpts: ->
super()
= ".cui-resizable-handle"
init: ->
super()
for d in ["ne","nw","se","sw","s","n","e","w"]
CUI.dom.append(, CUI.dom.element("DIV", "cui-drag-drop-select-resizable": d, class: "cui-resizable-handle cui-resizable-handle-"+d))
before_drag: (ev, $target) ->
super(ev, $target)
CUI.globalDrag.resize = $target.getAttribute("cui-drag-drop-select-resizable")
init_drag: (ev, $target) ->
#if $target.is(".cui-resizable-handle")
CUI.Draggable::init_drag.call(@, ev, $target)
# else
# # ignore this
# return
start_drag: (ev, $target, diff) ->
if
return
do_drag: (ev, $target, diff) ->
if
return
# gets the new pos from start and diff depending
# on the resize direction
getResizePos: (start, diff, limitRect=) =>
switch CUI.globalDrag.resize
when "se"
pos = w: start.w+diff.x, h: start.h+diff.y, fix: ["n","w"]
when "sw"
pos = w: start.w-diff.x, x: start.x+diff.x, h: start.h+diff.y, fix: ["n","e"]
when "ne"
pos = w: start.w+diff.x, y: start.y+diff.y, h: start.h-diff.y, fix: ["s","e"]
when "nw"
pos = w: start.w-diff.x, x: start.x+diff.x, y: start.y+diff.y, h: start.h-diff.y, fix: ["e","s"]
when "s"
pos = h: start.h+diff.y, fix: ["n"]
when "n"
pos = h: start.h-diff.y, y: start.y+diff.y, fix: ["s"]
when "e"
pos = w: start.w+diff.x, fix: ["w"]
when "w"
pos = w: start.w-diff.x, x: start.x+diff.x, fix: ["e"]