From 2c6c60307b60bba8aec9b510e0214d949fb3419c Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Mon, 20 Jan 2014 12:15:20 +0100 Subject: [PATCH] Disable body scrolling in Thang List This overwrites the native scrolling behavior for the thangs-list div by manually setting the value of @scrollTop --- app/views/editor/level/thangs_tab_view.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/views/editor/level/thangs_tab_view.coffee b/app/views/editor/level/thangs_tab_view.coffee index c936a8858..a74a12c9d 100644 --- a/app/views/editor/level/thangs_tab_view.coffee +++ b/app/views/editor/level/thangs_tab_view.coffee @@ -43,7 +43,7 @@ module.exports = class ThangsTabView extends View 'sprite:mouse-up': 'onSpriteMouseUp' 'sprite:double-clicked': 'onSpriteDoubleClicked' 'surface:stage-mouse-down': 'onStageMouseDown' - + shortcuts: 'esc': -> @selectAddThang() @@ -70,12 +70,17 @@ module.exports = class ThangsTabView extends View return if @startsLoading super() $('.tab-content').click @selectAddThang + $('#thangs-list').bind 'mousewheel', @preventBodyScrollingInThangList key 'left', _.bind @moveAddThangSelection, @, -1 key 'right', _.bind @moveAddThangSelection, @, 1 key 'delete, del, backspace', @deleteSelectedExtantThang key 'f', => Backbone.Mediator.publish('level-set-debug', debug: not @surface.debug) key 'g', => Backbone.Mediator.publish('level-set-grid', grid: not @surface.gridShowing()) + preventBodyScrollingInThangList: (e) -> + @scrollTop += (if e.deltaY < 0 then 1 else -1) * 30 + e.preventDefault() + onLevelLoaded: (e) -> @level = e.level return if @startsLoading