Skip to content

Instantly share code, notes, and snippets.

@MrOrz
Created January 30, 2014 19:49
Show Gist options
  • Save MrOrz/8717358 to your computer and use it in GitHub Desktop.
Save MrOrz/8717358 to your computer and use it in GitHub Desktop.
DIsable scrolling outside, scrapped from facebook's compressed JS.
__d("Scrollable", ["Event", "Parent", "UserAgent"], function(a, b, c, d, e, f) {
var g = b('Event'), h = b('Parent'), i = b('UserAgent'), j = function(event) {
var m = h.byClass(event.getTarget(), 'scrollable');
if (!m)
return;
if ((typeof event.axis !== 'undefined' && event.axis === event.HORIZONTAL_AXIS) ||
(event.wheelDeltaX && !event.wheelDeltaY) || (event.deltaX && !event.deltaY))
return;
var n = event.wheelDelta || -event.deltaY || -event.detail,
o = m.scrollHeight, p = m.clientHeight;
if (o > p) {
var q = m.scrollTop;
if ((n > 0 && q === 0) || (n < 0 && q >= o - p)) {
event.prevent();
} else if (i.ie() < 9)
if (m.currentStyle) {
var r = m.currentStyle.fontSize;
if (r.indexOf('px') < 0) {
var s = document.createElement('div');
s.style.fontSize = r;
s.style.height = '1em';
r = s.style.pixelHeight;
} else
r = parseInt(r, 10);
m.scrollTop = q - Math.round(n / 120 * r);
event.prevent();
}
}
}, k = document.documentElement;
if (i.firefox()) {
var l = ('WheelEvent' in window) ? 'wheel' : 'DOMMouseScroll';
k.addEventListener(l, j, false);
} else
g.listen(k, 'mousewheel', j);
});
__d("LegacyScrollableArea.react", ["Scrollable", "Bootloader", "React", "Style", "cx"], function(a, b, c, d, e, f) {
b('Scrollable');
var g = b('Bootloader'), h = b('React'), i = b('Style'), j = b('cx'), k = "uiScrollableArea native", l = "uiScrollableAreaWrap scrollable", m = "uiScrollableAreaBody", n = "uiScrollableAreaContent", o = h.createClass({displayName: 'ReactLegacyScrollableArea',render: function() {
var p = {height: this.props.height};
return this.transferPropsTo(h.DOM.div({className: k,ref: "root",style: p}, h.DOM.div({className: l}, h.DOM.div({className: m,ref: "body"}, h.DOM.div({className: n}, this.props.children)))));
},getArea: function() {
return this._area;
},componentDidMount: function() {
g.loadModules(["ScrollableArea"], this._loadScrollableArea);
},_loadScrollableArea: function(p) {
this._area = p.fromNative(this.refs.root.getDOMNode(), {fade: this.props.fade,persistent: this.props.persistent,shadow: this.props.shadow === undefined ? true : this.props.shadow});
var q = this.refs.body.getDOMNode();
i.set(q, 'width', this.props.width + 'px');
this.props.onScroll && this._area.subscribe('scroll', this.props.onScroll);
}});
e.exports = o;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment