Question

I was searching for Lavalamp menu solution and I found this little script. I am not sure if that's the best one around but looks nice and can be easily modified.

However it contain one error in console and I don't like errors so any help would be appreciated.

Uncaught TypeError: Cannot read property 'left' of null

Lavalamp Menu Original Source

Lavalamp Menu Fix JS Fiddle

You can go to that JS Fiddle fix and see in console when going through the menu it will show that property error.

I don't know how to resolve this, so any tips ?

Was it helpful?

Solution

fixed it like so inside the 'mouseleave' branch:

        if ($this.siblings('li.active').offset()) {
            left = $this.siblings('li.active').offset().left - ($this.closest('.' + lavalamp).offset().left);
            width = $this.siblings('li.active').width();

            $this.closest('ul').next('div.floatr').css({
                "width": width + "px",
                "left": left + "px"

            });
         }

OTHER TIPS

It is due to line 35 of the javascript section of the fiddle.

$this.siblings('li.active')

Does not return anything, which is why the Chrome debugger returns the error Cannot read property 'left' of null

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top