GithubHelp home page GithubHelp logo

lirancohen / stickup Goto Github PK

View Code? Open in Web Editor NEW
1.5K 1.5K 619.0 683 KB

stickUp a jQuery Plugin for sticky navigation menus.

License: GNU Lesser General Public License v3.0

JavaScript 88.58% CSS 11.42%

stickup's People

Contributors

lirancohen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stickup's Issues

error:needs arguments when arguments is provided

I'm using Modernizr to load stickUp, and I have a marginTop offset, but stickUp returns error:needs arguments when arguments are provided.

var $stickupWrapper = $('.nav-wrapper');

if (Modernizr.mq('only all and (min-width: 880px)'))
    Modernizr.load([{
        load: '/wp-content/themes/minera/assets/javascripts/vendor/stickup.min.js',
        complete: function() {

            $stickupWrapper.stickUp({
                marginTop: '-52px'
            });

        }
    }]);

Hello, can I release multiple Stickup on the basis of Stickup ?

Hello, because of the needs of the project, I have modified the StickUp source code, to support multiple StickUp, I want to put up in the github, using the MIT license, hope to get your support,!In the demo, I will add content on the basis of your demo,don't know if I can?

if `div.stuckMenu` next element is empty,`currentMarginT` is `NaN`

My jQuery version is 1.8.
I find that if div.stuckMenu next element is empty,currentMarginT is NaN

 currentMarginT = parseInt($(this).closest('div').css('margin-top')) // line 64

it causes a problem that code does not work in line 100 ~ 103,

$('.stuckMenu').next().closest('div').css({
    'margin-top': stickyHeight + stickyMarginB + currentMarginT + 'px'
}, 10);

Trigger events [enhancement]

Hi LiranCohen,

When the active class change to another item you should trigger an event with de last item and the new item activated.

Thanks!

Uncaught TypeError

Hope you can help me asap.

I'm using joomla and having set the code like the documentation but I recieve an error:

Uncaught TypeError: undefined is not a function(index):1233
(anonymous function) jquery.min.js:2
m.Callbacks. jjquery.min.js:2
m.Callbacks.k.fireWith jquery.min.js:2
m.extend.ready jquery.min.js:2 J

what can I do?

isStuck is not removed

My nav menu is inside of a bootstrap accordion. When I start scrolling it jumps to the top of the page which is what I want. However, if I scroll back to the top, the isStuck class is not removed so the bar always appears at the top once it is first triggered. Have to refresh the page to remove it

Offset top option

Hi

I can not see an option to set top offset, this causes a problem when the sticky navigation is already on the top of the page.

I changed this line of code:

vartop = parseInt($(this).offset().top);

to this:

vartop = parseInt($(this).offset().top + 5);

and now it works with a 5px top offset, is there another way you suggest which is a bit cleaner than what I did here?

Debounce scrolling

It wouldn't be better to limit (with a delay) the execution of functions inside the scroll event? Scroll event fires continuously in certain browsers.

scrolled = false;
$(window).on("scroll", function() {
  scrolled = true;
});

setInterval(function() {
  if(scrolled) {
     scrolled = false;

    // your code
    varscroll = parseInt($(document).scrollTop());
    //...
}, 500);

[enhancement] Add missing bower.json.

Hey, maintainer(s) of LiranCohen/stickUp!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library LiranCohen/stickUp is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "LiranCohen/stickUp",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

Using this plugin with dynamic elements

I have a problem with the vartop variable. It´s actually used as soon as I load the plugin and gets bound to the scroll event. I call the stickUp function from ajax callback because I am using the sticky feature for a progress bar.

Bacause the scroll event is bound and the vartop is not defined it will throw some errors on javascript console.

My workaround is, initialize vartop during the load of your plugin. Then there´s no error and the value gets a real value as soon as I call the stickUp function.

var stickyMarginB = 0;
        var currentMarginT = 0;
        var topMargin = 0;
        var vartop = 0;
        $(window).scroll(function(event){
            var st = $(this).scrollTop();
            if (st > lastScrollTop){

vartop is undefined

when adding the js to a new html and not call "stickUp" function, each time when scroll happens, it report error: "vartop is not defined".

Navbar fixed to bottom, stickUp to work only when showing new content

I have a portfolio website that has a hidden content area when you click the "view more" button on the navbar. The navbar is absolute positioned to the bottom of the page.

When you click "view more", the page scrolls up 100px and shows more content.

I want the navbar stickUp to be active only when the navbar reaches the top (with hidden content) and then, when I scroll to the top, my navbar remains as if there were no stickUp.

Is there any way I can do this?

Please lint your code

Ignoring all these warnings is not a good thing:

/*jshint -W018 */
/*jshint -W082 */
/*jshint -W041 */
/*jshint -W065 */
/*jshint -W069 */
....

Also note mixed tab and space usage.

Multiple stickUp elements

When applying to multiple elements, the isStuck class is applied to all elements when the first element is made sticky.

I tried a header and a sidebar. Where the header should activate after scrolling past the header and the sidebar should activate when scrolling past the sidebar, but when the page loads, and you scroll past the header, the sidebar is also activated with the isStuck class making both elements show to the top. The sidebar in this case should not have the isStuck class until scrolling down more.

Changed Top Margin

Hi- nice plugin! It works well, but I noticed that if the top margin of the menu changes (ie something above the element in the DOM slides larger) the topMargin of the menu doesn't update accordingly, which can cause the menu to overlap elements above it. I believe the fix would be to check and see if the menu's initial y position has changed prior to this line:

if(vartop < varscroll + topMargin){

Maybe something like this (didn't test this):

var morePadding = 0;
//If the initial y position of the menu is now less than the y position of the menu
if (initial_y < current_y) {
  //give more padding to the margin before adding the isStuck class
  morePadding = current_y - initial_y;
}
if (vartop < varscroll + topMargin + morePadding) {

The only problem with the above approach is that it doesn't take into account the changing y position of the menu as you scroll down the page.

deactivate on mobile devices

Hello,

First, thank you for this plugin.

I'd like to not display it on mobile as it crashes my site. Could you tell me what code lines to add please?

Thanks a lot

Florian

Sorry, the problem came from somewhere else!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.