B
B
Blah Blag2015-07-26 14:27:31
JavaScript
Blah Blag, 2015-07-26 14:27:31

For some reason, the Scroll jquery action is repeated 2 times instead of once, what could be the problem?

I use the Mausevel plugin, for some reason this script repeats all this 2 times, well, this is because there are 2 elements. If there are more elements, then there will be more repetitions.

$(window).on('mousewheel', function(event) {
                var CL = $(".case-left"), CR = $(".case-right"), CLHeight = CL.height(), CR = CR.height(), CLength = CL.length;
                $(window).resize(function() {
                    var CLHeight = CL.height(), CR = CR.height();
                });
                for(var i = 1; i < CLength; i++) {
                    if(event.deltaY > 0)
                        CL.animate({ "top": CLHeight }, 200);
                        console.log(CLHeight);
                    if(event.deltaY < 0)
                        CL.animate({ "top": -CLHeight }, 200);
                        console.log(CLHeight);
                }
            });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alastor, 2015-07-26
@Alastor

why does the resize event bind on scroll each time?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question