Coder Social home page Coder Social logo

Comments (7)

rochal avatar rochal commented on August 27, 2024

hey joeytheman, can you set up a demo page where this issue is visible?

from jquery-slimscroll.

tcz avatar tcz commented on August 27, 2024

This feature would be lovely indeed.

from jquery-slimscroll.

joeytheman avatar joeytheman commented on August 27, 2024

In my case it is not needed. I didn't initially realize the scroller automatically adjusted if additional content was added. Before I discovered this I wrote some code to remove the slim scrol div s and re initialize slim scroll after content was added.

from jquery-slimscroll.

tcz avatar tcz commented on August 27, 2024

I need it to adjust the height in case the size of the container changes.

from jquery-slimscroll.

joeytheman avatar joeytheman commented on August 27, 2024

Did you test if the slim scroll automatically adjusts?

If it doesn't here is the function I came up with.

window.activateSlimScroll = function() {
  var height, opts, slimscroll, slimscrolls, t, t_height, _i, _len;
  slimscrolls = $('.newSlimScroll');
  for (_i = 0, _len = slimscrolls.length; _i < _len; _i++) {
      slimscroll = slimscrolls[_i];
  t = $(slimscroll);
  }
  // Check if slimScroll is already activated
  if (t.parent().attr('class') === 'slimScrollDiv') {
      t.unwrap();
  t.parent().find('.slimScrollBar, .slimScrollRail').remove();
  }
 // Activate slimScroll
  t_height = t.height();
  height = t.data('slim-scroll-height');
  opts = {
      height: height,
      start: t.data('slim-scroll-start')
  };
  if (t_height > 250) {
      if (height) {
          if (t_height > height) {
              t.slimScroll(opts);
          }
          } else {
              t.slimScroll(opts);
          }
          }
          return slimscrolls.removeClass('newSlimScroll');
          };

It runs in an ajax:complete callback on elements with the .newSlimScroll class checking for an existing slim scroll and removing it before initializing a new one. Additional options can be set using html5 data attribute.

Let me know if you have any questions or if I can be of any other assistance.

from jquery-slimscroll.

tcz avatar tcz commented on August 27, 2024

For what I saw it doesn't really adjust. Also if I call it twice I get two scrollbars.
I'd like to keep all logic related to slimScroll ion the slimScroll library, hence the importance of this this issue to me.

from jquery-slimscroll.

rochal avatar rochal commented on August 27, 2024

from version 1.1.0 onwards slimscroll will recalculate the scrollbar size when you call it again on the same element.

So now, in your ajax callbacks you can simply call: $("#myElement").slimScroll() again.

from jquery-slimscroll.

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.