Skip to content

Commit

Permalink
Merge pull request jasny#501 from Minstel/443-How_to_close_the_left_h…
Browse files Browse the repository at this point in the history
…and_nav_for_really_small_screens

Menu width should always be smaller then screen width (fixes jasny#443)
  • Loading branch information
jasny authored Jan 20, 2017
2 parents 32776b6 + a1c4a67 commit 6d42b2a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion js/offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
modal: false
}

OffCanvas.prototype.setWidth = function () {
var size = this.$element.outerWidth()
var max = $(window).width()
max -= 68 //Minimum space between menu and screen edge

this.$element.css('width', size > max ? max : size)
}

OffCanvas.prototype.offset = function () {
switch (this.placement) {
case 'left':
Expand Down Expand Up @@ -176,7 +184,9 @@
if (startEvent.isDefaultPrevented()) return

this.state = 'slide-in'
this.calcPlacement();
this.$element.css('width', '')
this.calcPlacement()
this.setWidth()

var elements = this.getCanvasElements()
var placement = this.placement
Expand Down

0 comments on commit 6d42b2a

Please sign in to comment.