Coder Social home page Coder Social logo

richard1320 / lava-lamp Goto Github PK

View Code? Open in Web Editor NEW
38.0 38.0 8.0 541 KB

A JavaScript animation plugin for menus. It creates a div that moves when you mouse over an element, giving it an elastic animation.

JavaScript 100.00%
animations css css-animations css3 css3-animations lava-lamp mouse

lava-lamp's People

Contributors

dependabot[bot] avatar richard1320 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lava-lamp's Issues

Can't get 'update' method to work with BS ScrollSpy

Hello, thanks for the amazing library, I've been using it on many projects :)

I'm working on a single page website with a sticky menu, and I'm using Bootstrap 4's ScrollSpy which adds the '.active' class to the menu item related to the currently visible section.

I can use $(window).on('activate.bs.scrollspy') to trigger a callback once ScrollSpy has added the '.active' class to the currently visible section.

I'm hoping to have the lavalamp-object to follow the .active class on the menu as the user scrolls through the page, so here is my code, pretty simple:

HTML:

<ul id="main-menu">

	<li class="lava-active">
	   <a class="active" href="#">A</a>
	</li>

	<li>
	   <a href="#">B</a>
	</li>

	<li>
	   <a href="#">C</a>
	</li>

	<li>
	   <a href="#">D</a>
	</li>

</ul>

JS:

	$('#main-menu').lavalamp({
		activeObj: '.lava-active'
	});

	$(window).on('activate.bs.scrollspy', function () {

		$('#main-menu li.lava-active').removeClass('lava-active');
		$('#main-menu li .active').parent().addClass('lava-active');

		$('#main-menu').lavalamp('update');
		
	});

I think the flow here should be pretty straight forward but for the love of me I can't get Lavalamp to update. I've also tried with autoUpdate: true but still no luck. The lava-active class is being correctly assigned/removed to the li elements.

If I use this code it kinda works but the lavalamp-object obviously starts from the far left every time and it's also very bad practice performance-wise:

	$(window).on('activate.bs.scrollspy', function () {

		$('#main-menu').lavalamp();

	});

Any help would be highly appreciated :)

Thank you very much!

Global scope

Hi!
You have the following code:

enter = function() { ...
...
leave = function() {...

I think exposing enter and leave functions to the global scope is not required. I tried just to add var before them and it seems everything still works fine.

What if we enable it on focus as well?

Hello @Richard1320! I was using your script today and I noticed that we aren't enabling it on focus, just on hover, so I checked out the code and came here just to discuss with you what you think about it. Do you agree? Would it be an improvement? If won't have time to do that just let me know, maybe I can help you with that and make you a PR sometime soon, since I am the one who's asking you this. Best wishes to you and thanks for the project. Bye!

component not working as desired

Hi,

We are using this component on my website for few months now. But yesterday we came across 2 issues, they are listed below:

  1. When we toggle the tabs, and check the Console on firebug. We can see an error, but functionality wise it works fine:

TypeError: destination.position(...) is null

... h=destination.outerHeight(margins);var t=destination.position().top || 0;var l=...

  1. This is a major issue: When we click on the tabs a hash (#) gets appended on the url. Now if we navigate to any other page and click back button, page loads with that hash (#) already in place in the url. And then tabs stops working. Infact if # is already there in the URL, tabs stop working completely.

You can find both the error on our website page: http://www.researchaffiliates.com/Our%20Firm/Our%20Team/Pages/ourteam.aspx#

Can you please provide us a solution ASAP.

zIndex

The items.addClass('lavalamp-item').css({ zIndex ..}) was causing problems for me. I imagine this could cause problems for others. I tried shifting my other z-indexes around so I wouldn’t have the change the JS; but then the behavior of ‘lavalamp-object’ became erratic. I ended up removing items.addClass('lavalamp-item').css in the 2 places all together.

My setup was ‘menu > li > a’ and I have ‘lavalamp- object’ over ‘li’ under ‘a’ and it looks really nice. Feature request 1: an option to turn off 'lavalamp-item' css
Feature request 2: delay before return.

Lavalamp Breaks with new query 3.1.0

Dear Richard1320,

When I updated to jquery 3.1.0 on my website, the lava lamp plugin broke. Do you know of a patch for that?

Thanks,
llewcellist

Lavalamp not updating on scroll

Hi,

I am trying to get the lavalamp effect to update as the page scrolls into different sections. I have the 'active' class changing on each li element as the page scrolls using the code below. But for some reason the lavalamp plugin isn't updating it's position.

var sections = $('.menu-update'),

        links = $('#menu-main li');

        $(window).scroll(function() {

            var currentPosition = $(this).scrollTop();

            sections.each(function() {

                var top = $(this).offset().top,

                    bottom = top + $(this).height();

                if (currentPosition >= top && currentPosition <= bottom) {

                    links.removeClass('active');

                    $('a[href="#' + this.id + '"]').parent().addClass('active');

                }

            });

        });

Is there a way to force lavalamp to update? Maybe something like

$('#menu-main').lavalamp('update');

Thanks!

LL and LESS

Because LL is ready before LESS has finished rendering the page, the lavalamp-object is often out of place.
Here’s the solution i placed in a later JS file:
if(less||false){ less.pageLoadFinished.then(function(){ $('.lavalamp .active').mouseover() }) }

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.