Sha256: df0fedc3b45c379b72af3fee5d3a4acc41ae3454e459d2e9faabb1d73217c02e

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

/*
---
 
script: Scrollable.js
 
description: For all the scrollbars you always wanted
 
license: Public domain (http://unlicense.org).

authors: Yaroslaff Fedin
 
requires:
  - LSD.Mixin
  - LSD.Behavior
  - Widgets/LSD.Widget.Scrollbar

provides: 
  - LSD.Mixin.Scrollable
 
...
*/

LSD.Mixin.Scrollable = new Class({
  options: {
    events: {
      self: {
        resize: 'showScrollbars'
      },
      element: {
        mousewheel: 'onMousewheel'
      }
    }
  },
  
  onMousewheel: function(event) {
    var scrollbar = this.vertical || this.horizontal;
    if (scrollbar) scrollbar.track.element.fireEvent('mousewheel', event  );
  },
  
  showScrollbars: function(size) {
    if (!size) size = this.size;
    var scrolled = document.id(this.getScrolled());
    scrolled.setStyles(size)
    scrolled.setStyle('overflow', 'hidden');
    if (size.width < scrolled.scrollWidth) {
      if (this.getHorizontalScrollbar().parentNode != this) this.horizontal.inject(this);
      this.horizontal.slider.set(this.horizontal.now)
    } else if (this.horizontal) this.horizontal.dispose();
    
    if (size.height < scrolled.scrollHeight) {
      if (this.getVerticalScrollbar().parentNode != this) this.vertical.inject(this);
        this.vertical.slider.set(this.vertical.now)
    } else if (this.vertical) this.vertical.dispose();
  },
  
  getVerticalScrollbar: function() {
    return (this.vertical || (this.vertical = this.buildLayout('scrollbar[mode=vertical]')))
  },
  
  getHorizontalScrollbar: function() {
    return (this.horizontal || (this.horizontal = this.buildLayout('scrollbar[mode=horizontal]')))
  },
  
  getScrolled: Macro.defaults(function() {
    return this.getWrapper();
  })
});

LSD.Behavior.define('[scrollable]', LSD.Mixin.Scrollable);

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lsd_rails-0.1.2 Packages/lsd/Source/Mixin/Scrollable.js
lsd_rails-0.1.1 Packages/lsd/Source/Mixin/Scrollable.js
lsd_rails-0.1 Packages/lsd/Source/Mixin/Scrollable.js