kdf
Version:
78 lines (66 loc) • 2.31 kB
text/coffeescript
KDView = require './../../core/view.coffee'
module.exports = class KDSpotlightView extends KDView
constructor:(options = {}, data)->
options.cssClass = KD.utils.curry "kdspotlightview", options.cssClass
options.margin ?= 50
options.radial ?= yes
options.isRemovable ?= yes
super options, data
"shadow" unless options.radial
createElements: ->
{isRemovable} =
for position, boundaries of
{ width, height, top, left } = boundaries
if width > 0 and height > 0
view = new KDView
cssClass : KD.utils.curry "kdoverlay", position
size : { width, height }
position : { top, left }
if isRemovable
view.on "click", =>
"OverlayDestroyed"
view
getBoundaries: ->
{radial} =
delegate =
top = delegate.getY()
left = delegate.getX()
width = delegate.getWidth()
height = delegate.getHeight()
margin = "margin"
windowWidth = window.innerWidth
windowHeight = window.innerHeight
width = height = Math.min width, height if radial
topHeight = top - margin
leftWidth = left - margin
bottomHeight = windowHeight - (top + height + margin)
boundaries =
top :
top : 0
left : 0
width : windowWidth
height : topHeight
left :
top : topHeight
left : 0
width : leftWidth
height : windowHeight - top + margin
bottom :
top : top + height + margin
left : leftWidth
width : windowWidth - left + margin
height : bottomHeight
right :
top : topHeight
left : left + width + margin
width : windowWidth - (left + width + margin)
height : windowHeight - (bottomHeight + topHeight)
main :
top : topHeight
left : leftWidth
width : width + margin + margin
height : height + margin + margin
return boundaries