Pass container width to draggable instance. Relative to 5569caa687

This commit is contained in:
vieron
2013-06-13 11:43:37 +02:00
parent 2aa9b55433
commit 3d755fd793
2 changed files with 16 additions and 9 deletions
+5 -2
View File
@@ -15,7 +15,8 @@
offset_left: 0,
autoscroll: true,
ignore_dragging: ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON'],
handle: null
handle: null,
container_width: 0 // 0 == auto
// drag: function(e){},
// start : function(e, ui){},
// stop : function(e){}
@@ -247,7 +248,9 @@
this.el_init_offset = this.$player.offset();
this.player_width = this.$player.width();
this.player_height = this.$player.height();
this.player_max_left = (this.$container.width() - this.player_width +
var container_width = this.options.container_width || this.$container.width();
this.player_max_left = (container_width - this.player_width +
this.options.offset_left);
if (this.options.start) {
+11 -7
View File
@@ -642,6 +642,7 @@
var self = this;
var draggable_options = $.extend(true, {}, this.options.draggable, {
offset_left: this.options.widget_margins[0],
container_width: this.container_width,
start: function(event, ui) {
self.$widgets.filter('.player-revert')
.removeClass('player-revert');
@@ -2502,14 +2503,15 @@
fn.generate_grid_and_stylesheet = function() {
var aw = this.$wrapper.width();
var ah = this.$wrapper.height();
var max_cols = this.options.max_cols;
var cols = Math.floor(aw / this.min_widget_width) +
this.options.extra_cols;
var actual_cols = this.$widgets.map(function() {
return $(this).attr('data-col');
});
actual_cols = Array.prototype.slice.call(actual_cols, 0);
}).get();
//needed to pass tests with phantomjs
actual_cols.length || (actual_cols = [0]);
@@ -2522,17 +2524,19 @@
});
this.cols = Math.max(min_cols, cols, this.options.min_cols);
var max_cols = this.options.max_cols;
if (max_cols >= -1 && max_cols >= min_cols) {
if (max_cols < this.cols) {
this.cols = max_cols;
}
if (max_cols > -1 && max_cols >= min_cols && max_cols < this.cols) {
this.cols = max_cols;
}
this.rows = Math.max(max_rows, this.options.min_rows);
this.baseX = ($(window).width() - aw) / 2;
this.baseY = this.$wrapper.offset().top;
this.container_width = (this.cols * this.options.widget_base_dimensions[0]) +
(this.cols * this.options.widget_margins[0]) + this.options.widget_margins[0];
if (this.options.autogenerate_stylesheet) {
this.generate_stylesheet();
}