UNPKG

@cantonjs/react-scroll-view

Version:

react scroll component using intersection observer API

41 lines (31 loc) 1.57 kB
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } import { eventOptions } from './util'; var PullingDown = function () { function PullingDown(dom) { _classCallCheck(this, PullingDown); this._preventWindowScroll = function (ev) { ev.cancelable !== false && ev.preventDefault(); }; this._dom = dom; this.isActive = false; } _createClass(PullingDown, [{ key: 'start', value: function start() { window.addEventListener('touchmove', this._preventWindowScroll, eventOptions); this.isActive = true; this._overflowStyle = this._dom.style.overflowY; this._dom.style.overflowY = 'hidden'; } }, { key: 'stop', value: function stop() { window.removeEventListener('touchmove', this._preventWindowScroll, eventOptions); this.isActive = false; this._dom.style.overflowY = this._overflowStyle; } }]); return PullingDown; }(); export default PullingDown;