Commit 7b143a81 authored by Jacob Schatz's avatar Jacob Schatz

fixes scrollbar jump by making discussion the same size as the sidebar when...

fixes scrollbar jump by making discussion the same size as the sidebar when sidebar is bigger, and not allowing affix to do fixed position on the sidebar
parent 46b56fc7
...@@ -15,16 +15,7 @@ class @IssuableContext ...@@ -15,16 +15,7 @@ class @IssuableContext
$(@).width($(@).outerWidth()) $(@).width($(@).outerWidth())
.on 'affixed-top.bs.affix affixed-bottom.bs.affix', -> .on 'affixed-top.bs.affix affixed-bottom.bs.affix', ->
$(@).width('') $(@).width('')
$discussion = $('.issuable-discussion')
$sidebar = $('.issuable-sidebar')
discussionHeight = $discussion.height()
sidebarHeight = $sidebar.height()
console.log(sidebarHeight,discussionHeight)
if sidebarHeight > discussionHeight
$discussion.height(sidebarHeight + 50)
console.log('fixing issues')
return
# No affix if discussion is smaller than sidebar
$('.issuable-affix').affix offset: $('.issuable-affix').affix offset:
top: -> top: ->
@top = ($('.issuable-affix').offset().top - 70) @top = ($('.issuable-affix').offset().top - 70)
......
...@@ -6,10 +6,25 @@ class @Issue ...@@ -6,10 +6,25 @@ class @Issue
constructor: -> constructor: ->
# Prevent duplicate event bindings # Prevent duplicate event bindings
@disableTaskList() @disableTaskList()
@fixAffixScroll()
if $('a.btn-close').length if $('a.btn-close').length
@initTaskList() @initTaskList()
@initIssueBtnEventListeners() @initIssueBtnEventListeners()
fixAffixScroll: ->
fixAffix = ->
$discussion = $('.issuable-discussion')
$sidebar = $('.issuable-sidebar')
if $sidebar.hasClass('no-affix')
$sidebar.removeClass(['affix-top','affix'])
discussionHeight = $discussion.height()
sidebarHeight = $sidebar.height()
if sidebarHeight > discussionHeight
$discussion.height(sidebarHeight + 50)
$sidebar.addClass('no-affix')
$(window).on('resize', fixAffix)
fixAffix()
initTaskList: -> initTaskList: ->
$('.detail-page-description .js-task-list-container').taskList('enable') $('.detail-page-description .js-task-list-container').taskList('enable')
$(document).on 'tasklist:changed', '.detail-page-description .js-task-list-container', @updateTaskList $(document).on 'tasklist:changed', '.detail-page-description .js-task-list-container', @updateTaskList
......
...@@ -15,6 +15,8 @@ class @MergeRequest ...@@ -15,6 +15,8 @@ class @MergeRequest
this.$('.show-all-commits').on 'click', => this.$('.show-all-commits').on 'click', =>
this.showAllCommits() this.showAllCommits()
@fixAffixScroll();
@initTabs() @initTabs()
# Prevent duplicate event bindings # Prevent duplicate event bindings
...@@ -28,6 +30,20 @@ class @MergeRequest ...@@ -28,6 +30,20 @@ class @MergeRequest
$: (selector) -> $: (selector) ->
this.$el.find(selector) this.$el.find(selector)
fixAffixScroll: ->
fixAffix = ->
$discussion = $('.issuable-discussion')
$sidebar = $('.issuable-sidebar')
if $sidebar.hasClass('no-affix')
$sidebar.removeClass(['affix-top','affix'])
discussionHeight = $discussion.height()
sidebarHeight = $sidebar.height()
if sidebarHeight > discussionHeight
$discussion.height(sidebarHeight + 50)
$sidebar.addClass('no-affix')
$(window).on('resize', fixAffix)
fixAffix()
initTabs: -> initTabs: ->
if @opts.action != 'new' if @opts.action != 'new'
# `MergeRequests#new` has no tab-persisting or lazy-loading behavior # `MergeRequests#new` has no tab-persisting or lazy-loading behavior
...@@ -50,10 +66,11 @@ class @MergeRequest ...@@ -50,10 +66,11 @@ class @MergeRequest
$this = $(this) $this = $(this)
if $this.data('submitted') if $this.data('submitted')
return return
e.preventDefault()
e.stopImmediatePropagation()
shouldSubmit = $this.hasClass('btn-comment') shouldSubmit = $this.hasClass('btn-comment')
console.log("shouldSubmit")
if shouldSubmit if shouldSubmit
e.preventDefault()
e.stopImmediatePropagation()
_this.submitNoteForm($this.closest('form'),$this) _this.submitNoteForm($this.closest('form'),$this)
submitNoteForm: (form, $button) => submitNoteForm: (form, $button) =>
......
...@@ -20,6 +20,11 @@ ...@@ -20,6 +20,11 @@
position: fixed; position: fixed;
top: 70px; top: 70px;
margin-right: 35px; margin-right: 35px;
&.no-affix {
position: relative;
top: 0;
}
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment