Giter VIP home page Giter VIP logo

Comments (2)

rihards-simanovics avatar rihards-simanovics commented on June 13, 2024

Unfortunately, when you start using this plugin as your main scroll controller, you are bound to it, so you have to play by its rules.

When the popup gets triggered, you need to destroy the nice scroll on the body (remove it from the element) and when the popup closes, reinstate it by using simple event handlers.

Since it's a jQuery plugin, I will provide examples in jQuery. Please note that I started using nice scroll recently and am looking to solve another issue, but since your one is the one I had to research myself, I hope I could help.

So to solve your issue, you must call for this function .remove. It isn't documented here https://github.com/inuyaksa/jquery.nicescroll#dependencies but it will help you remove the nice scroll.

If you have a look at the source code, you will see all possible functions you can trigger:

NiceScrollArray.prototype, ['show', 'hide', 'toggle', 'onResize', 'resize', 'remove', 'stop', 'doScrollPos'],

So all you need to do is this:

jQuery( ($) => {
    const options = {
        cursorminheight: x,
        background: y,
        cursorcolor: z,
    };

    $('body').niceScroll(options);

    // Listen for when popup has been triggered (read up on popup documentation to find out real triggers)
    $('.popup-in').on('trigger of your choice', function() {
        // Use getNiceScroll() as you are not initialising nice scroll but actually modifying one,
        // and than remove it using the function .remove()
        $('body').getNiceScroll().remove();
    });

    // Listen for when popup gets closed (read up on popup documentation to find out real triggers)
    $('.popup-out').on('trigger of your choice', function() {
        // Reinitialise Nice scroll like you do when you initially load the page
        $('body').niceScroll(options);
    });
});

from jquery.nicescroll.

wireinet avatar wireinet commented on June 13, 2024

Hello! And Thank you for this incredibly detailed answer!

from jquery.nicescroll.

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.