Q2W3 Fixed Widget - Version 1.0.3

Version Description

  • Normalized plugin behavior when sidebar is longer then main content. Note: possible overlaping with footer is still exists.
Download this release

Release Info

Developer Max Bond
Plugin Icon 128x128 Q2W3 Fixed Widget
Version 1.0.3
Comparing to
See all releases

Code changes from version 1.0.2 to 1.0.3

Files changed (3) hide show
  1. js/functions.js +16 -6
  2. q2w3-fixed-widget.php +2 -2
  3. readme.txt +4 -1
js/functions.js CHANGED
@@ -1,26 +1,36 @@
1
  jQuery(window).load(function () {
2
- var vertical_offset = 10;
3
  for (var i = 0; i < q2w3_fixed_widgets.length; i++) {
4
  widget = jQuery('#' + q2w3_fixed_widgets[i]);
5
  if ( widget.attr('id') ) { // element existsts
6
- q2w3_fixed_widget(widget, vertical_offset);
7
- vertical_offset += widget.outerHeight(true);
8
  }
9
  }
10
  });
11
- function q2w3_fixed_widget(widget, vertical_offset) {
12
  var widget_width = widget.css('width');
13
  var widget_margin = widget.css('margin');
14
  var widget_padding = widget.css('padding');
15
- var top = widget.offset().top - vertical_offset;
 
 
16
  jQuery(window).scroll(function (event) {
17
  if ( jQuery(this).scrollTop() >= top ) { // fixed
 
 
 
 
18
  widget.css('position', 'fixed');
19
  widget.css('width', widget_width);
20
  widget.css('margin', widget_margin);
21
  widget.css('padding', widget_padding);
22
- widget.css('top', vertical_offset);
23
  } else { // normal
 
 
 
 
24
  widget.css('position', 'static');
25
  }
26
  });
1
  jQuery(window).load(function () {
2
+ var offset_top = 10;
3
  for (var i = 0; i < q2w3_fixed_widgets.length; i++) {
4
  widget = jQuery('#' + q2w3_fixed_widgets[i]);
5
  if ( widget.attr('id') ) { // element existsts
6
+ q2w3_fixed_widget(widget, offset_top);
7
+ offset_top += widget.outerHeight(true);
8
  }
9
  }
10
  });
11
+ function q2w3_fixed_widget(widget, offset_top) {
12
  var widget_width = widget.css('width');
13
  var widget_margin = widget.css('margin');
14
  var widget_padding = widget.css('padding');
15
+ var top = widget.offset().top - offset_top;
16
+ var parent_height = widget.parent().height();
17
+ var update_parent_height = false;
18
  jQuery(window).scroll(function (event) {
19
  if ( jQuery(this).scrollTop() >= top ) { // fixed
20
+ if ( !update_parent_height ) { // needed when sidebar is longer then main content
21
+ widget.parent().height(parent_height);
22
+ update_parent_height = true;
23
+ }
24
  widget.css('position', 'fixed');
25
  widget.css('width', widget_width);
26
  widget.css('margin', widget_margin);
27
  widget.css('padding', widget_padding);
28
+ widget.css('top', offset_top);
29
  } else { // normal
30
+ if ( update_parent_height ) {
31
+ widget.parent().removeAttr('style');
32
+ update_parent_height = false;
33
+ }
34
  widget.css('position', 'static');
35
  }
36
  });
q2w3-fixed-widget.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Q2W3 Fixed Widget
4
  Plugin URI: http://www.q2w3.ru/q2w3-fixed-widget-wordpress-plugin/
5
  Description: Fixes positioning of the selected widgets, when the page is scrolled down.
6
  Author: Max Bond
7
- Version: 1.0.2
8
  Author URI: http://www.q2w3.ru/
9
  */
10
 
@@ -44,7 +44,7 @@ class q2w3_fixed_widget {
44
 
45
  wp_enqueue_script('jquery');
46
 
47
- wp_enqueue_script('q2w3-fixed-widget', plugin_dir_url( __FILE__ ) . 'js/functions.js', array('jquery'), '1.2', true);
48
 
49
  }
50
 
4
  Plugin URI: http://www.q2w3.ru/q2w3-fixed-widget-wordpress-plugin/
5
  Description: Fixes positioning of the selected widgets, when the page is scrolled down.
6
  Author: Max Bond
7
+ Version: 1.0.3
8
  Author URI: http://www.q2w3.ru/
9
  */
10
 
44
 
45
  wp_enqueue_script('jquery');
46
 
47
+ wp_enqueue_script('q2w3-fixed-widget', plugin_dir_url( __FILE__ ) . 'js/functions.js', array('jquery'), '1.3', true);
48
 
49
  }
50
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.q2w3.ru/q2w3-fixed-widget-wordpress-plugin/#donate
4
  Tags: q2w3, widget, fixed, scroll, fixed scroll, floating, floating widget, fixed widget, sticky, sticky widget, sidebar
5
  Requires at least: 3.0
6
  Tested up to: 3.4.2
7
- Stable tag: 1.0.2
8
 
9
  Fixes positioning of the selected widgets, when the page is scrolled down.
10
 
@@ -47,6 +47,9 @@ There are several reasons:
47
 
48
  == Changelog ==
49
 
 
 
 
50
  = 1.0.2 =
51
  * Fixed problem with widgets displayed only on certain pages.
52
  * Optimized javascript code.
4
  Tags: q2w3, widget, fixed, scroll, fixed scroll, floating, floating widget, fixed widget, sticky, sticky widget, sidebar
5
  Requires at least: 3.0
6
  Tested up to: 3.4.2
7
+ Stable tag: 1.0.3
8
 
9
  Fixes positioning of the selected widgets, when the page is scrolled down.
10
 
47
 
48
  == Changelog ==
49
 
50
+ = 1.0.3 =
51
+ * Normalized plugin behavior when sidebar is longer then main content. Note: possible overlaping with footer is still exists.
52
+
53
  = 1.0.2 =
54
  * Fixed problem with widgets displayed only on certain pages.
55
  * Optimized javascript code.