Skip to content

Commit

Permalink
Fix select tool so clicking on a box doesn't clear it but clicking ou…
Browse files Browse the repository at this point in the history
…tside does
  • Loading branch information
mcmire committed Apr 1, 2012
1 parent 913d71b commit 10ee92e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 45 deletions.
33 changes: 21 additions & 12 deletions app/javascripts/editor/viewport.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ define 'editor.viewport', ->
return if mouseupBound
console.log 'binding mouseup'
mouseupBound = true
# @$elem.bind("mouseup.#{evtns}", clearSelection)
@$elem.bind("mouseup.#{evtns}", clearSelection)
unbindMouseup = =>
return if not mouseupBound
console.log 'unbinding mouseup'
mouseupBound = false
# @$elem.unbind(clearSelection)
@$elem.unbind(clearSelection)

adjustCoords = (p) =>
x: p.x - @bounds.x1
Expand All @@ -237,12 +237,12 @@ define 'editor.viewport', ->
evt.preventDefault()
mouse = {x: evt.pageX, y: evt.pageY}

dragOffsetX = Math.abs(evt.pageX - mouseDownAt.x)
dragOffsetY = Math.abs(evt.pageY - mouseDownAt.y)
return unless (
dragOffsetX > SELECTION_ACTIVATION_OFFSET or
dragOffsetY > SELECTION_ACTIVATION_OFFSET
)
# dragOffsetX = Math.abs(evt.pageX - mouseDownAt.x)
# dragOffsetY = Math.abs(evt.pageY - mouseDownAt.y)
# return unless (
# dragOffsetX > SELECTION_ACTIVATION_OFFSET or
# dragOffsetY > SELECTION_ACTIVATION_OFFSET
# )

unbindMouseup()

Expand All @@ -267,13 +267,22 @@ define 'editor.viewport', ->
if w is 0 and h is 0
selection.$box.hide()
else
selection.$box.show().moveTo({x, y}).size({w, h})
selection.$box
.show()
.moveTo({x, y})
.size(w: w-1, h: h-1)

.delegate '.editor-selection-box', "mousedown.#{evtns}", (evt) ->
console.log 'selection box mousedown'
evt.preventDefault()
unbindMouseup()

.delegate '.editor-selection-box', "mouseup.#{evtns}", (evt) ->
console.log 'selection box mouseup'
# because otherwise the selection will be cleared
evt.stopPropagation()
evt.preventDefault()
# delay the re-addition of the mouseup event ever so slightly
# otherwise it gets fired immediately (since we're in the mouseup
# event ourselves)
setTimeout bindMouseup, 0

.bind "mouseup.#{evtns}", (evt) =>
@$elem.unbind "mousemove.#{evtns}"
Expand Down
21 changes: 1 addition & 20 deletions app/stylesheets/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ body {
}

#editor-viewport {
// &.editor-tool-normal {
// cursor: auto;
// }
// &.editor-tool-hand {
// cursor: url('/images/editor/tool-hand.gif'), auto;
// }
// &.editor-tool-select {
// cursor: url('/images/editor/tool-select.gif'), auto;
// }
// &.editor-tool-bucket {
// cursor: url('/images/editor/tool-bucket.gif'), auto;
// }

.editor-layer, .editor-layer-content, .editor-layer-bg {
@include absfill();
}
Expand All @@ -58,7 +45,6 @@ body {
opacity: 1
}
.editor-layer-bg {
// background: white;
opacity: 0.5;
}
}
Expand Down Expand Up @@ -181,17 +167,12 @@ $sidebar-width: 300px;
}
}

// #editor-sticky-cursor {
// position: absolute;
// z-index: 100;
// }

// marching ants like it's 1995
// http://sunpig.com/martin/archives/2010/02/10/marching-ants-in-css.html
.editor-selection-box {
position: absolute;
z-index: 10;
background-color: white;
// background-color: rgba(255,255,255,0.15);
border: 1px dashed black;
-moz-border-image: url(/images/editor/selection-border.gif) 1 repeat;
-webkit-border-image: url(/images/editor/selection-border.gif) 1 repeat;
Expand Down
Binary file added public/images/editor/selection-border-trans.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions public/javascripts/app/editor/viewport.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion public/stylesheets/app/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ body {
.editor-selection-box {
position: absolute;
z-index: 10;
background-color: white;
border: 1px dashed black;
-moz-border-image: url(/images/editor/selection-border.gif) 1 repeat;
-webkit-border-image: url(/images/editor/selection-border.gif) 1 repeat;
Expand Down

0 comments on commit 10ee92e

Please sign in to comment.