Sha256: d82c713a826c2b60403bee3acbd29b28a1cd96190fc54e66968a489dbd805458
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
#= require 'mixins/storable' #= require 'mixins/hideable' class OverlayMe.Draggable extends Backbone.View tagName: 'div' css_attributes_to_save: ['top', 'left', 'display', 'opacity'] initialize: (attributes, options) -> super(attributes, options) @loadCss(@el, options.default_css) engageMove: (event) -> event.preventDefault() @moving = true @lastX = event.clientX @lastY = event.clientY $o(window).bind 'mymousemove', (event, mouseEvent) => @updateOverlay(mouseEvent.clientX - @lastX, mouseEvent.clientY - @lastY) @lastX = mouseEvent.clientX @lastY = mouseEvent.clientY $o(@el).addClass 'on-move' endMove: (event) -> @moving = false $o(window).unbind('mymousemove') $o(@el).removeClass 'on-move' toggleMove: (event) -> if @moving @endMove(event) else @engageMove(event) updateOverlay: (x, y) -> newX = parseInt($o(@el).css('left')) + x newY = parseInt($o(@el).css('top')) + y $o(@el).css({ top:"#{newY}px", left:"#{newX}px"}) @saveCss() render: -> @el # extending few mixins - thx Derick - http://stackoverflow.com/questions/7853731/proper-way-of-doing-view-mixins-in-backbone _.extend OverlayMe.Draggable.prototype, OverlayMe.Mixin.Storable _.extend OverlayMe.Draggable.prototype, OverlayMe.Mixin.Hideable
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
overlay_me-0.13.4 | javascripts/coffeescripts/draggable.js.coffee |
overlay_me-0.13.0 | javascripts/draggable.js.coffee |
overlay_me-0.12.1 | javascripts/draggable.js.coffee |