UNPKG

@cantonjs/react-scroll-view

Version:

react scroll component using intersection observer API

60 lines (48 loc) 2.04 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"); } } var EntryState = function () { function EntryState(entry, debugId) { _classCallCheck(this, EntryState); this.entry = entry; this.debugId = debugId; } _createClass(EntryState, [{ key: "isOffsetTop", get: function get() { var entry = this.entry; return !entry.isIntersecting && entry.boundingClientRect.bottom < entry.rootBounds.bottom; } }, { key: "isOffsetBottom", get: function get() { var entry = this.entry; return !entry.isIntersecting && entry.boundingClientRect.bottom > entry.rootBounds.bottom; } }, { key: "isTopVisible", get: function get() { var entry = this.entry; return entry.isIntersecting && entry.boundingClientRect.top >= entry.rootBounds.top; } }, { key: "isBottomVisible", get: function get() { var entry = this.entry; return entry.isIntersecting && entry.boundingClientRect.bottom <= entry.rootBounds.bottom; } }, { key: "isTopBoundary", get: function get() { var entry = this.entry; return entry.isIntersecting && entry.boundingClientRect.top === entry.rootBounds.top; } }, { key: "isBottomBoundary", get: function get() { var entry = this.entry; return entry.isIntersecting && entry.boundingClientRect.bottom === entry.rootBounds.bottom; } }]); return EntryState; }(); export default EntryState;