Code Monkey home page Code Monkey logo

Comments (11)

lukehaas avatar lukehaas commented on May 25, 2024 1

Ok, thanks. I will investigate this.

from scrollify.

lukehaas avatar lukehaas commented on May 25, 2024

I've now introduced a destroy method which may be what you're looking for.

from scrollify.

MrzAOK avatar MrzAOK commented on May 25, 2024

How would I implement the destroy method on the following when the screen width is lower than 800px?
$.scrollify({
section : "section",
sectionName : "section-name",
easing: "easeOutExpo",
scrollSpeed: 1100,
offset : 0,
scrollbars: true,
before:function() {},
after:function() {},
afterResize: function() {}
});

from scrollify.

peterbode1989 avatar peterbode1989 commented on May 25, 2024

Simple, just add this code to your script:

function disableScrollify(toggle){
if(toggle){
$.scrollify.destroy();
}else{
$.scrollify.enable();
console.log('this should work, if it doesn't you can always reload the page');
}
}

$(document).ready(function(){
if($(window).width() < 768){
disableScrollify(1);
}else{
disableScrollify(0);
}
$( window ).resize(function() {
if($(window).width() < 768){
disableScrollify(1);
}else{
disableScrollify(0);
}
});
});

Ps. this scrips also checks if the size is big enough to use Scrollify again.. but .enable() seems broken when i test it (that's why i suggested to reload the page).

from scrollify.

lukehaas avatar lukehaas commented on May 25, 2024

The enable method won't work there. It works in conjunction with the disable method, not the destroy method

from scrollify.

peterbode1989 avatar peterbode1989 commented on May 25, 2024

Already though so.. after i posted this, i was reading through the documentation. Simple solution is to initialize it again (correct me if i'm wrong, haha).
But still it's a great plugin, keep up the good work!

from scrollify.

lukehaas avatar lukehaas commented on May 25, 2024

Yes, in this case you would have to initialise it again. But it would be much simpler to just use the disable and enable methods

from scrollify.

peterbode1989 avatar peterbode1989 commented on May 25, 2024

Ah, i got to agree on that!

from scrollify.

AlexandraKlein avatar AlexandraKlein commented on May 25, 2024

The following disables scroll when resized from desktop to mobile without a reload. Any suggestions?

var settings = {
            section : '.scroll-section',
            easing: 'easeInCubic',
            scrollSpeed: 1000,
            offset : 0,
            scrollbars: true,
            setHeights: true,
            overflowScroll: true,
            updateHash: false,
            touchScroll: true,
            afterResize: function() {
                if( $(window).width() < 768 ) {
                    $.scrollify.destroy();
                }

                $('.scroll-section').removeClass('active previous next');
            },
            before: function(index) {
                $('.scroll-section').eq(index).addClass('active')
                    .siblings('.scroll-section')
                    .removeClass('active');

                $('.scroll-section').eq(index - 1).addClass('previous')
                    .siblings('.scroll-section')
                    .removeClass('previous');

                $('.scroll-section').eq(index + 1).addClass('next')
                    .siblings('.scroll-section')
                    .removeClass('next');
            }
        };

        function disableScrollify(toggle){
            if(toggle){
                $.scrollify.destroy();
            } else {
                $.scrollify(settings);
            }
        }

        $(document).ready(function(){
            if($(window).width() < 768){
                disableScrollify(1);
            } else {
                disableScrollify(0);
            }

            $(window).resize(function() {
                if($(window).width() < 768){
                    disableScrollify(1);
                }else{
                    disableScrollify(0);
                }
            });
        });

        $.scrollify(settings);

from scrollify.

lukehaas avatar lukehaas commented on May 25, 2024

It doesn't make sense to destroy/ re-initialise Scrollify. You would be better off initialising it once and then disabling/enabling it with the methods $.scrollify.disable() and $.scrollify.enable()

from scrollify.

AlexandraKlein avatar AlexandraKlein commented on May 25, 2024

Hi! Thanks for responding so quickly. When I use the following code...

function disableScrollify(toggle){
            if(toggle){
                $.scrollify.disable();
            } else {
                $.scrollify.enable();
            }
        }

... scrollify does not reinitialize when resizing from mobile to desktop.

from scrollify.

Related Issues (20)

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.