react-native-intersection-observer
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,16 +0,6 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.withIO = exports.IOScrollView = exports.IOContext = exports.InView = exports.IntersectionObserver = void 0; | ||
var IntersectionObserver_1 = __importDefault(require("./IntersectionObserver")); | ||
exports.IntersectionObserver = IntersectionObserver_1.default; | ||
var InView_1 = __importDefault(require("./InView")); | ||
exports.InView = InView_1.default; | ||
var IOContext_1 = __importDefault(require("./IOContext")); | ||
exports.IOContext = IOContext_1.default; | ||
var IOScrollView_1 = __importDefault(require("./IOScrollView")); | ||
exports.IOScrollView = IOScrollView_1.default; | ||
var withIO_1 = __importDefault(require("./withIO")); | ||
exports.withIO = withIO_1.default; | ||
import IntersectionObserver from './IntersectionObserver'; | ||
import InView from './InView'; | ||
import IOContext from './IOContext'; | ||
import IOScrollView from './IOScrollView'; | ||
import withIO from './withIO'; | ||
export { IntersectionObserver, InView, IOContext, IOScrollView, withIO }; |
@@ -13,2 +13,3 @@ import { LayoutRectangle, NativeScrollEvent } from 'react-native'; | ||
measureLayout: (node: any, callback: (x: number, y: number, width: number, height: number) => void) => void; | ||
onLayout?: () => void; | ||
} | ||
@@ -15,0 +16,0 @@ export interface IntersectionObserverEntry { |
@@ -1,9 +0,3 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.defaultRootMargin = void 0; | ||
var throttle_1 = __importDefault(require("lodash/throttle")); | ||
exports.defaultRootMargin = { | ||
import throttle from 'lodash/throttle'; | ||
export const defaultRootMargin = { | ||
left: 0, | ||
@@ -14,28 +8,26 @@ right: 0, | ||
}; | ||
var IntersectionObserver = (function () { | ||
function IntersectionObserver(callback, options) { | ||
var _this = this; | ||
this.measureTarget = function (target) { | ||
var rootNode = _this.options.root.node; | ||
class IntersectionObserver { | ||
constructor(callback, options) { | ||
this.measureTarget = (target) => { | ||
const rootNode = this.options.root.node; | ||
if (rootNode) { | ||
target.measureLayout(rootNode, function (x, y, width, height) { | ||
target.measureLayout(rootNode, (x, y, width, height) => { | ||
target.layout = { | ||
x: x, | ||
y: y, | ||
width: width, | ||
height: height, | ||
x, | ||
y, | ||
width, | ||
height, | ||
}; | ||
_this.handleScroll(); | ||
this.handleScroll(); | ||
}); | ||
} | ||
}; | ||
this.handleLayout = throttle_1.default(function () { | ||
for (var index = 0; index < _this.targets.length; index += 1) { | ||
_this.measureTarget(_this.targets[index]); | ||
this.handleLayout = throttle(() => { | ||
for (let index = 0; index < this.targets.length; index += 1) { | ||
this.measureTarget(this.targets[index]); | ||
} | ||
}, 300, { leading: false, trailing: true }); | ||
this.handleScroll = throttle_1.default(function () { | ||
var _a; | ||
var rootMargin = ((_a = _this.options) === null || _a === void 0 ? void 0 : _a.rootMargin) || exports.defaultRootMargin; | ||
var _b = _this.options.root, horizontal = _b.horizontal, _c = _b.current, contentOffset = _c.contentOffset, contentSize = _c.contentSize, layoutMeasurement = _c.layoutMeasurement; | ||
this.handleScroll = throttle(() => { | ||
const rootMargin = this.options?.rootMargin || defaultRootMargin; | ||
const { horizontal, current: { contentOffset, contentSize, layoutMeasurement, }, } = this.options.root; | ||
if (contentSize.width <= 0 || | ||
@@ -47,9 +39,9 @@ contentSize.height <= 0 || | ||
} | ||
var contentOffsetWithLayout = horizontal | ||
const contentOffsetWithLayout = horizontal | ||
? contentOffset.x + layoutMeasurement.width | ||
: contentOffset.y + layoutMeasurement.height; | ||
var changedTargets = []; | ||
for (var index = 0; index < _this.targets.length; index += 1) { | ||
var target = _this.targets[index]; | ||
var targetLayout = target.layout; | ||
const changedTargets = []; | ||
for (let index = 0; index < this.targets.length; index += 1) { | ||
const target = this.targets[index]; | ||
const targetLayout = target.layout; | ||
if (!targetLayout || | ||
@@ -60,3 +52,3 @@ targetLayout.width === 0 || | ||
} | ||
var isIntersecting = false; | ||
let isIntersecting = false; | ||
if (horizontal) { | ||
@@ -79,8 +71,8 @@ isIntersecting = | ||
changedTargets.push({ | ||
target: target, | ||
isIntersecting: isIntersecting, | ||
target, | ||
isIntersecting, | ||
}); | ||
} | ||
} | ||
_this.callback(changedTargets); | ||
this.callback(changedTargets); | ||
}, 100, { leading: false, trailing: true }); | ||
@@ -93,17 +85,16 @@ this.callback = callback; | ||
} | ||
IntersectionObserver.prototype.observe = function (target) { | ||
var index = this.targets.indexOf(target); | ||
observe(target) { | ||
const index = this.targets.indexOf(target); | ||
if (index < 0) { | ||
target.onLayout = () => this.measureTarget(target); | ||
this.targets.push(target); | ||
this.measureTarget(target); | ||
} | ||
}; | ||
IntersectionObserver.prototype.unobserve = function (target) { | ||
var index = this.targets.indexOf(target); | ||
} | ||
unobserve(target) { | ||
const index = this.targets.indexOf(target); | ||
if (index >= 0) { | ||
this.targets.splice(index, 1); | ||
} | ||
}; | ||
return IntersectionObserver; | ||
}()); | ||
exports.default = IntersectionObserver; | ||
} | ||
} | ||
export default IntersectionObserver; |
@@ -37,2 +37,3 @@ import React, { ComponentType, PureComponent, ReactElement, ReactNode, RefObject } from 'react'; | ||
protected handleRef: (ref: any) => void; | ||
protected handleLayout: (event: LayoutChangeEvent) => void; | ||
measureInWindow: (...args: any) => void; | ||
@@ -39,0 +40,0 @@ measureLayout: (...args: any) => void; |
@@ -1,75 +0,14 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_1 = __importStar(require("react")); | ||
var react_native_1 = require("react-native"); | ||
var IOContext_1 = __importDefault(require("./IOContext")); | ||
var InView = (function (_super) { | ||
__extends(InView, _super); | ||
function InView(props) { | ||
var _this = _super.call(this, props) || this; | ||
_this.mounted = false; | ||
_this.handleChange = function (inView) { | ||
var _a, _b; | ||
if (_this.mounted) { | ||
var _c = _this.props, triggerOnce = _c.triggerOnce, onChange = _c.onChange; | ||
import React, { PureComponent, } from 'react'; | ||
import { View } from 'react-native'; | ||
import IOContext from './IOContext'; | ||
class InView extends PureComponent { | ||
constructor(props) { | ||
super(props); | ||
this.mounted = false; | ||
this.handleChange = (inView) => { | ||
if (this.mounted) { | ||
const { triggerOnce, onChange } = this.props; | ||
if (inView && triggerOnce) { | ||
if ((_a = _this.context) === null || _a === void 0 ? void 0 : _a.manager) { | ||
(_b = _this.context) === null || _b === void 0 ? void 0 : _b.manager.unobserve(_this.element); | ||
if (this.context?.manager) { | ||
this.context?.manager.unobserve(this.element); | ||
} | ||
@@ -82,46 +21,39 @@ } | ||
}; | ||
_this.handleRef = function (ref) { | ||
_this.view = ref; | ||
this.handleRef = (ref) => { | ||
this.view = ref; | ||
}; | ||
_this.measureInWindow = function () { | ||
var _a; | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
this.handleLayout = (event) => { | ||
const { nativeEvent: { layout }, } = event; | ||
if (layout.width !== this.element.layout.width || | ||
layout.height !== this.element.layout.height) { | ||
this.element.layout = { | ||
...this.element.layout, | ||
width: layout.width, | ||
height: layout.height, | ||
}; | ||
if (this.element.onLayout) { | ||
this.element.onLayout(); | ||
} | ||
} | ||
(_a = _this.view).measureInWindow.apply(_a, args); | ||
}; | ||
_this.measureLayout = function () { | ||
var _a; | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
const { onLayout } = this.props; | ||
if (onLayout) { | ||
onLayout(event); | ||
} | ||
(_a = _this.view).measureLayout.apply(_a, args); | ||
}; | ||
_this.setNativeProps = function () { | ||
var _a; | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
(_a = _this.view).setNativeProps.apply(_a, args); | ||
this.measureInWindow = (...args) => { | ||
this.view.measureInWindow(...args); | ||
}; | ||
_this.focus = function () { | ||
var _a; | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
(_a = _this.view).focus.apply(_a, args); | ||
this.measureLayout = (...args) => { | ||
this.view.measureLayout(...args); | ||
}; | ||
_this.blur = function () { | ||
var _a; | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
(_a = _this.view).blur.apply(_a, args); | ||
this.setNativeProps = (...args) => { | ||
this.view.setNativeProps(...args); | ||
}; | ||
_this.element = { | ||
this.focus = (...args) => { | ||
this.view.focus(...args); | ||
}; | ||
this.blur = (...args) => { | ||
this.view.blur(...args); | ||
}; | ||
this.element = { | ||
inView: false, | ||
@@ -134,35 +66,31 @@ layout: { | ||
}, | ||
measureLayout: _this.measureLayout, | ||
measureLayout: this.measureLayout, | ||
}; | ||
return _this; | ||
} | ||
InView.prototype.componentDidMount = function () { | ||
var _a; | ||
componentDidMount() { | ||
this.mounted = true; | ||
if ((_a = this.context) === null || _a === void 0 ? void 0 : _a.manager) { | ||
if (this.context?.manager) { | ||
this.instance = this.context.manager.observe(this.element, this.handleChange); | ||
} | ||
}; | ||
InView.prototype.componentWillUnmount = function () { | ||
var _a; | ||
} | ||
componentWillUnmount() { | ||
this.mounted = false; | ||
if (((_a = this.context) === null || _a === void 0 ? void 0 : _a.manager) && this.instance) { | ||
if (this.context?.manager && this.instance) { | ||
this.context.manager.unobserve(this.element); | ||
} | ||
}; | ||
InView.prototype.render = function () { | ||
var _a = this.props, as = _a.as, children = _a.children, props = __rest(_a, ["as", "children"]); | ||
} | ||
render() { | ||
const { as, children, ...props } = this.props; | ||
if (typeof children === 'function') { | ||
return null; | ||
} | ||
var ViewComponent = (as || react_native_1.View); | ||
return (react_1.default.createElement(ViewComponent, __assign({}, props, { ref: this.handleRef }), children)); | ||
}; | ||
InView.contextType = IOContext_1.default; | ||
InView.defaultProps = { | ||
triggerOnce: false, | ||
as: react_native_1.View, | ||
}; | ||
return InView; | ||
}(react_1.PureComponent)); | ||
exports.default = InView; | ||
const ViewComponent = (as || View); | ||
return (React.createElement(ViewComponent, Object.assign({}, props, { ref: this.handleRef, onLayout: this.handleLayout }), children)); | ||
} | ||
} | ||
InView.contextType = IOContext; | ||
InView.defaultProps = { | ||
triggerOnce: false, | ||
as: View, | ||
}; | ||
export default InView; |
@@ -1,7 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_1 = require("react"); | ||
var IOContext = react_1.createContext({ | ||
import { createContext } from 'react'; | ||
const IOContext = createContext({ | ||
manager: null, | ||
}); | ||
exports.default = IOContext; | ||
export default IOContext; |
@@ -1,15 +0,9 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var IntersectionObserver_1 = __importDefault(require("./IntersectionObserver")); | ||
var IOManager = (function () { | ||
function IOManager(options) { | ||
var _this = this; | ||
import IntersectionObserver from './IntersectionObserver'; | ||
class IOManager { | ||
constructor(options) { | ||
this.instanceMap = new Map(); | ||
this.handleChange = function (entries) { | ||
for (var index = 0; index < entries.length; index += 1) { | ||
var _a = entries[index], target = _a.target, isIntersecting = _a.isIntersecting; | ||
var instance = _this.instanceMap.get(target); | ||
this.handleChange = (entries) => { | ||
for (let index = 0; index < entries.length; index += 1) { | ||
const { target, isIntersecting } = entries[index]; | ||
const instance = this.instanceMap.get(target); | ||
if (instance) { | ||
@@ -20,7 +14,7 @@ instance.callback(isIntersecting); | ||
}; | ||
this.io = new IntersectionObserver_1.default(this.handleChange, options); | ||
this.io = new IntersectionObserver(this.handleChange, options); | ||
this.observerId = 0; | ||
} | ||
IOManager.prototype.observe = function (element, callback) { | ||
var existInstance = this.instanceMap.get(element); | ||
observe(element, callback) { | ||
const existInstance = this.instanceMap.get(element); | ||
if (existInstance) { | ||
@@ -30,5 +24,5 @@ return existInstance; | ||
this.observerId += 1; | ||
var instance = { | ||
callback: callback, | ||
element: element, | ||
const instance = { | ||
callback, | ||
element, | ||
observerId: this.observerId, | ||
@@ -40,4 +34,4 @@ observer: this.io, | ||
return instance; | ||
}; | ||
IOManager.prototype.unobserve = function (element) { | ||
} | ||
unobserve(element) { | ||
if (this.instanceMap.has(element)) { | ||
@@ -47,5 +41,4 @@ this.instanceMap.delete(element); | ||
} | ||
}; | ||
return IOManager; | ||
}()); | ||
exports.default = IOManager; | ||
} | ||
} | ||
export default IOManager; |
@@ -1,8 +0,3 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_native_1 = require("react-native"); | ||
var withIO_1 = __importDefault(require("./withIO")); | ||
exports.default = withIO_1.default(react_native_1.ScrollView); | ||
import { ScrollView } from 'react-native'; | ||
import withIntersectionObserver from './withIO'; | ||
export default withIntersectionObserver(ScrollView); |
@@ -1,67 +0,18 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_1 = __importStar(require("react")); | ||
var react_native_1 = require("react-native"); | ||
var IOContext_1 = __importDefault(require("./IOContext")); | ||
var IOManager_1 = __importDefault(require("./IOManager")); | ||
var withIO = function (ScrollableComponent) { | ||
var IOScrollableComponent = (function (_super) { | ||
__extends(IOScrollableComponent, _super); | ||
function IOScrollableComponent(props) { | ||
var _this = _super.call(this, props) || this; | ||
_this.handleContentSizeChange = function (width, height) { | ||
var contentSize = _this.root.current.contentSize; | ||
import React, { PureComponent, createRef } from 'react'; | ||
import { findNodeHandle, } from 'react-native'; | ||
import IOContext from './IOContext'; | ||
import IOManager from './IOManager'; | ||
const withIO = (ScrollableComponent) => { | ||
class IOScrollableComponent extends PureComponent { | ||
constructor(props) { | ||
super(props); | ||
this.handleContentSizeChange = (width, height) => { | ||
const { contentSize } = this.root.current; | ||
if (width !== contentSize.width || height !== contentSize.height) { | ||
_this.root.current.contentSize = { width: width, height: height }; | ||
if (width > 0 && height > 0 && _this.root.onLayout) { | ||
_this.root.onLayout(); | ||
this.root.current.contentSize = { width, height }; | ||
if (width > 0 && height > 0 && this.root.onLayout) { | ||
this.root.onLayout(); | ||
} | ||
} | ||
var onContentSizeChange = _this.props.onContentSizeChange; | ||
const { onContentSizeChange } = this.props; | ||
if (onContentSizeChange) { | ||
@@ -71,10 +22,10 @@ onContentSizeChange(width, height); | ||
}; | ||
_this.handleLayout = function (event) { | ||
var layout = event.nativeEvent.layout; | ||
var layoutMeasurement = _this.root.current.layoutMeasurement; | ||
this.handleLayout = (event) => { | ||
const { nativeEvent: { layout }, } = event; | ||
const { layoutMeasurement } = this.root.current; | ||
if (layoutMeasurement.width !== layout.width || | ||
layoutMeasurement.height !== layout.height) { | ||
_this.root.current.layoutMeasurement = layout; | ||
this.root.current.layoutMeasurement = layout; | ||
} | ||
var onLayout = _this.props.onLayout; | ||
const { onLayout } = this.props; | ||
if (onLayout) { | ||
@@ -84,8 +35,8 @@ onLayout(event); | ||
}; | ||
_this.handleScroll = function (event) { | ||
_this.root.current = event.nativeEvent; | ||
if (_this.root.onScroll) { | ||
_this.root.onScroll(_this.root.current); | ||
this.handleScroll = (event) => { | ||
this.root.current = event.nativeEvent; | ||
if (this.root.onScroll) { | ||
this.root.onScroll(this.root.current); | ||
} | ||
var onScroll = _this.props.onScroll; | ||
const { onScroll } = this.props; | ||
if (onScroll) { | ||
@@ -95,21 +46,17 @@ onScroll(event); | ||
}; | ||
_this.scrollToEnd = function (options) { | ||
var _a; | ||
(_a = _this.scroller.current) === null || _a === void 0 ? void 0 : _a.scrollToEnd(options); | ||
this.scrollToEnd = (options) => { | ||
this.scroller.current?.scrollToEnd(options); | ||
}; | ||
_this.getScrollResponder = function () { | ||
var _a; | ||
return (_a = _this.scroller.current) === null || _a === void 0 ? void 0 : _a.getScrollResponder(); | ||
this.getScrollResponder = () => { | ||
return this.scroller.current?.getScrollResponder(); | ||
}; | ||
_this.getScrollableNode = function () { | ||
var _a; | ||
return (_a = _this.scroller.current) === null || _a === void 0 ? void 0 : _a.getScrollableNode(); | ||
this.getScrollableNode = () => { | ||
return this.scroller.current?.getScrollableNode(); | ||
}; | ||
_this.getInnerViewNode = function () { | ||
var _a; | ||
return (_a = _this.scroller.current) === null || _a === void 0 ? void 0 : _a.getInnerViewNode(); | ||
this.getInnerViewNode = () => { | ||
return this.scroller.current?.getInnerViewNode(); | ||
}; | ||
var self = _this; | ||
_this.scroller = react_1.createRef(); | ||
_this.root = { | ||
const self = this; | ||
this.scroller = createRef(); | ||
this.root = { | ||
get node() { | ||
@@ -143,4 +90,4 @@ return self.node; | ||
}; | ||
var manager = new IOManager_1.default({ | ||
root: _this.root, | ||
const manager = new IOManager({ | ||
root: this.root, | ||
get rootMargin() { | ||
@@ -150,23 +97,20 @@ return self.props.rootMargin; | ||
}); | ||
_this.manager = manager; | ||
_this.contextValue = { | ||
manager: manager, | ||
this.manager = manager; | ||
this.contextValue = { | ||
manager, | ||
}; | ||
return _this; | ||
} | ||
IOScrollableComponent.prototype.componentDidMount = function () { | ||
this.node = react_native_1.findNodeHandle(this.scroller.current); | ||
}; | ||
IOScrollableComponent.prototype.scrollTo = function (y, x, animated) { | ||
var _a; | ||
(_a = this.scroller.current) === null || _a === void 0 ? void 0 : _a.scrollTo(y, x, animated); | ||
}; | ||
IOScrollableComponent.prototype.render = function () { | ||
return (react_1.default.createElement(IOContext_1.default.Provider, { value: this.contextValue }, | ||
react_1.default.createElement(ScrollableComponent, __assign({ scrollEventThrottle: 16 }, this.props, { ref: this.scroller, onContentSizeChange: this.handleContentSizeChange, onLayout: this.handleLayout, onScroll: this.handleScroll })))); | ||
}; | ||
return IOScrollableComponent; | ||
}(react_1.PureComponent)); | ||
componentDidMount() { | ||
this.node = findNodeHandle(this.scroller.current); | ||
} | ||
scrollTo(y, x, animated) { | ||
this.scroller.current?.scrollTo(y, x, animated); | ||
} | ||
render() { | ||
return (React.createElement(IOContext.Provider, { value: this.contextValue }, | ||
React.createElement(ScrollableComponent, Object.assign({ scrollEventThrottle: 16 }, this.props, { ref: this.scroller, onContentSizeChange: this.handleContentSizeChange, onLayout: this.handleLayout, onScroll: this.handleScroll })))); | ||
} | ||
} | ||
return IOScrollableComponent; | ||
}; | ||
exports.default = withIO; | ||
export default withIO; |
{ | ||
"name": "react-native-intersection-observer", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "react native intersection observer", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21768
493