UNPKG

@cantonjs/react-scroll-view

Version:

react scroll component using intersection observer API

61 lines (57 loc) 1.84 kB
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } import { isIOS } from '../util'; import { create } from '../Style'; export default create({ container: function container(style) { return _extends({ position: 'relative' }, style); }, main: function main(direction, disabled) { var _res; var overflowHidden = direction === 'vertical' ? 'overflowX' : 'overflowY'; var overflowScroll = direction === 'vertical' ? 'overflowY' : 'overflowX'; var res = (_res = { // all: 'inherit', position: 'relative', height: '100%', width: '100%' }, _defineProperty(_res, overflowHidden, 'hidden'), _defineProperty(_res, overflowScroll, disabled ? 'hidden' : isIOS ? 'scroll' : 'auto'), _res); if (isIOS) res.WebkitOverflowScrolling = 'touch'; return res; }, background: function background(direction) { var vertical = { width: '100%', height: 'calc(100% + 1px)' }; var horizontal = { width: 'calc(100% + 1px)', height: '100%' }; var style = direction === 'vertical' ? vertical : horizontal; return _extends({ position: 'absolute', top: 0, left: 0, zIndex: -1 }, style); }, endHook: function endHook(bottom) { return { position: 'relative', bottom: bottom }; }, fixedContainer: function fixedContainer(style) { return _extends({}, style, { position: 'absolute', left: 0, right: 0, top: 0, height: 0, zIndex: 666666 }); } });