Sticky Menu (or Anything!) on Scroll - Version 1.1.1

Version Description

  • Fixes viewport calculation bug.
Download this release

Release Info

Developer senff
Plugin Icon 128x128 Sticky Menu (or Anything!) on Scroll
Version 1.1.1
Comparing to
See all releases

Code changes from version 1.1 to 1.1.1

README.md CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://www.senff.com/plugins/sticky-anything-wp
5
  * Requires at least: 3.6
6
  * Tested up to: 4.0
7
- * Stable tag: 1.1
8
  * License: GPLv2 or later
9
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -59,6 +59,9 @@ For any other issues, please use the [WordPress.org forum](https://wordpress.org
59
 
60
  ## Changelog
61
 
 
 
 
62
  ### 1.1
63
  * Added functionality for optional minimum/maximum screen size
64
 
@@ -68,6 +71,9 @@ For any other issues, please use the [WordPress.org forum](https://wordpress.org
68
 
69
  ## Upgrade Notice
70
 
 
 
 
71
  ### 1.1
72
  Added functionality: you can now set a minimum and/or maximum screen size where the element should be sticky (handy for responsive designs, should you not want your element to be sticky below or above certain screen sizes).
73
 
4
  * Plugin URI: http://www.senff.com/plugins/sticky-anything-wp
5
  * Requires at least: 3.6
6
  * Tested up to: 4.0
7
+ * Stable tag: 1.1.1
8
  * License: GPLv2 or later
9
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
59
 
60
  ## Changelog
61
 
62
+ ### 1.1.1
63
+ * Fixes viewport calculation bug
64
+
65
  ### 1.1
66
  * Added functionality for optional minimum/maximum screen size
67
 
71
 
72
  ## Upgrade Notice
73
 
74
+ ### 1.1.1
75
+ Fixes viewport calculation bug.
76
+
77
  ### 1.1
78
  Added functionality: you can now set a minimum and/or maximum screen size where the element should be sticky (handy for responsive designs, should you not want your element to be sticky below or above certain screen sizes).
79
 
assets/js/jq-sticky-anything.js CHANGED
@@ -1,5 +1,5 @@
1
  /**
2
- * @preserve Sticky Anything 1.1 | @senff | GPL2 Licensed
3
  */
4
 
5
  (function ($) {
@@ -45,7 +45,15 @@ function stickIt(stickyTop,minwidth,maxwidth) {
45
  var orgElementPos = $('.original').offset();
46
  orgElementTop = orgElementPos.top;
47
 
48
- if (($(window).scrollTop() >= (orgElementTop - stickyTop)) && ($(window).width() > minwidth) && ($(window).width() < maxwidth)) {
 
 
 
 
 
 
 
 
49
 
50
  // scrolled past the original position; now only show the cloned, sticky element.
51
 
1
  /**
2
+ * @preserve Sticky Anything 1.1.1 | @senff | GPL2 Licensed
3
  */
4
 
5
  (function ($) {
45
  var orgElementPos = $('.original').offset();
46
  orgElementTop = orgElementPos.top;
47
 
48
+ // Calculating actual viewport width
49
+ var e = window, a = 'inner';
50
+ if (!('innerWidth' in window )) {
51
+ a = 'client';
52
+ e = document.documentElement || document.body;
53
+ }
54
+ viewport = e[ a+'Width' ];
55
+
56
+ if (($(window).scrollTop() >= (orgElementTop - stickyTop)) && (viewport >= minwidth) && (viewport <= maxwidth)) {
57
 
58
  // scrolled past the original position; now only show the cloned, sticky element.
59
 
assets/js/jq-sticky-anything.min.js CHANGED
@@ -1,5 +1,5 @@
1
  /**
2
- * @preserve Sticky Anything 1.1 | @senff | GPL2 Licensed
3
  */
4
 
5
- (function(e){function t(t,n,r){var i=e(".original").offset();orgElementTop=i.top;if(e(window).scrollTop()>=orgElementTop-t&&e(window).width()>n&&e(window).width()<r){orgElement=e(".original");coordsOrgElement=orgElement.offset();leftOrgElement=coordsOrgElement.left;widthOrgElement=orgElement.width();e(".cloned").css("left",leftOrgElement+"px").css("top",t+"px").css("width",widthOrgElement+"px").show();e(".original").css("visibility","hidden")}else{e(".cloned").hide();e(".original").css("visibility","visible")}}e.fn.stickThis=function(n){var r=e.extend({top:0,minscreenwidth:0,maxscreenwidth:99999,zindex:1,debugmode:false},n);var i=e(this).length;if(i<1){if(r.debugmode==true){console.error("STICKY ANYTHING DEBUG: There are no elements with the selector/class/ID you selected.")}}else if(i>1){if(r.debugmode==true){console.error("STICKY ANYTHING DEBUG: There is more than one element with the selector/class/ID you selected. You can only make ONE element sticky.")}}else{e(this).addClass("original").clone().insertAfter(this).addClass("cloned").css("position","fixed").css("top",r.top+"px").css("margin-top","0").css("margin-left","0").css("z-index",r.zindex).removeClass("original").hide();checkElement=setInterval(function(){t(r.top,r.minscreenwidth,r.maxscreenwidth)},10)}return this}})(jQuery)
1
  /**
2
+ * @preserve Sticky Anything 1.1.1 | @senff | GPL2 Licensed
3
  */
4
 
5
+ (function(e){function t(t,n,r){var i=e(".original").offset();orgElementTop=i.top;var s=window,o="inner";if(!("innerWidth"in window)){o="client";s=document.documentElement||document.body}viewport=s[o+"Width"];if(e(window).scrollTop()>=orgElementTop-t&&viewport>=n&&viewport<=r){orgElement=e(".original");coordsOrgElement=orgElement.offset();leftOrgElement=coordsOrgElement.left;widthOrgElement=orgElement.width();e(".cloned").css("left",leftOrgElement+"px").css("top",t+"px").css("width",widthOrgElement+"px").show();e(".original").css("visibility","hidden")}else{e(".cloned").hide();e(".original").css("visibility","visible")}}e.fn.stickThis=function(n){var r=e.extend({top:0,minscreenwidth:0,maxscreenwidth:99999,zindex:1,debugmode:false},n);var i=e(this).length;if(i<1){if(r.debugmode==true){console.error("STICKY ANYTHING DEBUG: There are no elements with the selector/class/ID you selected.")}}else if(i>1){if(r.debugmode==true){console.error("STICKY ANYTHING DEBUG: There is more than one element with the selector/class/ID you selected. You can only make ONE element sticky.")}}else{e(this).addClass("original").clone().insertAfter(this).addClass("cloned").css("position","fixed").css("top",r.top+"px").css("margin-top","0").css("margin-left","0").css("z-index",r.zindex).removeClass("original").hide();checkElement=setInterval(function(){t(r.top,r.minscreenwidth,r.maxscreenwidth)},10)}return this}})(jQuery)
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: plugin, sticky, menu, scroll, element
4
  Plugin URI: http://www.senff.com/plugins/sticky-anything-wp
5
  Requires at least: 3.6
6
  Tested up to: 4.0
7
- Stable tag: 1.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -59,6 +59,9 @@ For any other issues, please use the [WordPress.org forum](https://wordpress.org
59
 
60
  == Changelog ==
61
 
 
 
 
62
  = 1.1 =
63
  * Added functionality for optional minimum/maximum screen size
64
 
@@ -68,6 +71,9 @@ For any other issues, please use the [WordPress.org forum](https://wordpress.org
68
 
69
  == Upgrade Notice ==
70
 
 
 
 
71
  = 1.1 =
72
  Added functionality: you can now set a minimum and/or maximum screen size where the element should be sticky (handy for responsive designs, should you not want your element to be sticky below or above certain screen sizes).
73
 
4
  Plugin URI: http://www.senff.com/plugins/sticky-anything-wp
5
  Requires at least: 3.6
6
  Tested up to: 4.0
7
+ Stable tag: 1.1.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
59
 
60
  == Changelog ==
61
 
62
+ = 1.1.1 =
63
+ * Fixes viewport calculation bug.
64
+
65
  = 1.1 =
66
  * Added functionality for optional minimum/maximum screen size
67
 
71
 
72
  == Upgrade Notice ==
73
 
74
+ = 1.1.1 =
75
+ Fixes viewport calculation bug.
76
+
77
  = 1.1 =
78
  Added functionality: you can now set a minimum and/or maximum screen size where the element should be sticky (handy for responsive designs, should you not want your element to be sticky below or above certain screen sizes).
79
 
sticky-menu-or-anything.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.senff.com/plugins/sticky-anything-wp
5
  Description: Pick any element on your page, and it will stick when it reaches the top of the page when you scroll down. Usually handy for navigation menus, but can be used for any (unique) element on your page.
6
  Author: Mark Senff
7
  Author URI: http://www.senff.com
8
- Version: 1.1
9
  */
10
 
11
  defined('ABSPATH') or die('Gorgonzola. Wow, BOB, wow.');
@@ -15,7 +15,7 @@ defined('ABSPATH') or die('Gorgonzola. Wow, BOB, wow.');
15
 
16
  if (!function_exists('sticky_anthing_default_options')) {
17
  function sticky_anthing_default_options() {
18
- $versionNum = '1.1';
19
  if (get_option('sticky_anything_options') === false) {
20
  $new_options['sa_version'] = $versionNum;
21
  $new_options['sa_element'] = '';
@@ -31,7 +31,7 @@ if (!function_exists('sticky_anthing_default_options')) {
31
 
32
  if (!function_exists('sticky_anything_update')) {
33
  function sticky_anything_update() {
34
- $versionNum = '1.1';
35
  $existing_options = get_option('sticky_anything_options');
36
 
37
  if(!isset($existing_options['sa_minscreenwidth'])) {
5
  Description: Pick any element on your page, and it will stick when it reaches the top of the page when you scroll down. Usually handy for navigation menus, but can be used for any (unique) element on your page.
6
  Author: Mark Senff
7
  Author URI: http://www.senff.com
8
+ Version: 1.1.1
9
  */
10
 
11
  defined('ABSPATH') or die('Gorgonzola. Wow, BOB, wow.');
15
 
16
  if (!function_exists('sticky_anthing_default_options')) {
17
  function sticky_anthing_default_options() {
18
+ $versionNum = '1.1.1';
19
  if (get_option('sticky_anything_options') === false) {
20
  $new_options['sa_version'] = $versionNum;
21
  $new_options['sa_element'] = '';
31
 
32
  if (!function_exists('sticky_anything_update')) {
33
  function sticky_anything_update() {
34
+ $versionNum = '1.1.1';
35
  $existing_options = get_option('sticky_anything_options');
36
 
37
  if(!isset($existing_options['sa_minscreenwidth'])) {