Skip to content

Commit

Permalink
add dynamic height to scrolling spell palette
Browse files Browse the repository at this point in the history
for that, remove previous height calculation, which seem way too
confusing and needless complex
  • Loading branch information
cauerego committed Jan 14, 2015
1 parent 819a5ba commit 9d00c74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/styles/play/level/tome/spell_palette.sass
Expand Up @@ -70,9 +70,9 @@
@include flex-wrap()
@include flex-column()
@include flex-align-content-start()
height: 230px
width: 98%
overflow: auto
flex-direction: row

.property-entry-item-group
display: inline-block
Expand Down
15 changes: 11 additions & 4 deletions app/views/play/level/tome/SpellPaletteView.coffee
Expand Up @@ -72,7 +72,7 @@ module.exports = class SpellPaletteView extends CocoView
if entryIndex is 0
entry.$el.addClass 'first-entry'
@$el.addClass 'hero'
@updateMaxHeight() unless application.isIPadApp
@updateHeight() unless application.isIPadApp

afterInsert: ->
super()
Expand All @@ -81,8 +81,9 @@ module.exports = class SpellPaletteView extends CocoView
updateCodeLanguage: (language) ->
@options.language = language

updateMaxHeight: ->
updateHeight: ->
return unless @isHero
###
nColumns = Math.floor @$el.find('.properties').innerWidth() / 212 # ~212px is a good max entry width; will always have 2 columns
columns = ({items: [], nEntries: 0} for i in [0 ... nColumns])
nRows = 0
Expand All @@ -94,10 +95,16 @@ module.exports = class SpellPaletteView extends CocoView
for column in columns
for item in column.items
item.detach().appendTo @$el.find('.properties')
# @$el.find('.properties').css('height', 19 * (nRows + 1))
@$el.find('.properties').css('height', 19 * (nRows + 1))
###
pal = @$el.find('img.code-palette-background')
height = 212 # just some default
if pal
height = pal.height() - 160
@$el.find('.properties').css('height', height)

onResize: (e) =>
# @updateMaxHeight()
@updateHeight()

createPalette: ->
Backbone.Mediator.publish 'tome:palette-cleared', {thangID: @thang.id}
Expand Down

0 comments on commit 9d00c74

Please sign in to comment.