question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to destroy() Optiscroll?

See original GitHub issue

First, thx 4 your great plugin! Secondly, how can I destroy() it on the jQuery way?

For Example, I initialize it like this:

$(document).ready(function (){
    scrollbar();
});

function scrollbar(){
    $('.box').optiscroll();
}

And try to destroy it like this (not working):

$(document).ready(function (){
    if ($('body').outerWidth() <= 800 ) {
       scrollbar.destroy();
    }
});

Whats my fail?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
albertogasparincommented, Jan 4, 2020

You have to call destroy on the Optiscroll instance, not on the function that creates it. You can get it by using data('optiscroll') on the element that has Optiscroll:

$(document).ready(function (){
    if ($('body').outerWidth() <= 800 ) {
       $('.box').data('optiscroll').destroy();
    }
});
0reactions
Overpoweredcommented, Jan 6, 2020

Thx again for your great support! Works perfect now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optiscroll/README.md at master · albertogasparin/Optiscroll · GitHub
destroy (). If you want to remove Optiscroll, this method will clean up the class names, unbind all events and remove the scrollbar...
Read more >
Optiscroll.js
$('selector').optiscroll(). Try it out: Initialize! Destroy. Don't see any difference? By default Optiscroll does not create custom scrollbars on iOS, ...
Read more >
jquery function destroy on scroll event - Stack Overflow
I have build so far a jquery function that stick html element to the top of the page when scrolling but destroy on...
Read more >
Optiscroll pointer - JSFiddle - Code Playground
clientW=i,e!==d){if(0===f&&0===g&&!b.body.contains(this.element))return this.destroy(),!1;this.fireCustomEvent("sizechange")}j(this.scrollbars,"update")}} ...
Read more >
Optiscroll Tests
Basics: Optiscroll should auto destroy itself (0, 2, 2)Rerun1011 ms. okay; okay. Public APIs: It should scrollTo(value, value, 0) (0, 2, 2)Rerun61 ms....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found