Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically appearing elements #59

Closed
urban-1 opened this issue May 27, 2013 · 1 comment
Closed

Dynamically appearing elements #59

urban-1 opened this issue May 27, 2013 · 1 comment

Comments

@urban-1
Copy link

urban-1 commented May 27, 2013

Hi,

This is a small fix for elements that appear on run-time (ie. onclick of a button) and their content changes. Since they have display hidden initially I had to call .antiscroll() every time I show an element, in order to reset the scroll bars (I don't know if there is a better way of doing this...).

Now this causes constant size expansion each time the element appears (due to the css width += scrollbarSize() in the initialization function). My solution was to remove this extra width/height in the destroy():

  Antiscroll.prototype.destroy = function () {

    this.inner.css({
        'width':  '-=' + (this.y ? scrollbarSize() : 0)
      , 'height': '-=' + (this.x ? scrollbarSize() : 0)
    });

    if (this.horizontal) {
      this.horizontal.destroy();
      this.horizontal = null
    }
    if (this.vertical) {
      this.vertical.destroy();
      this.vertical = null
    }
    return this;
  };

Please let me know if I am doing something wrong, but seems reasonable to me to add this code in destroy, just to leave the element in its original state. This will also solve problems when antiscroll() is called multiple times.

Andreas

@setthase
Copy link

setthase commented Jul 3, 2013

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants