UNPKG

@cantonjs/react-scroll-view

Version:

react scroll component using intersection observer API

68 lines (61 loc) 1.95 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); 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; }; var _util = require('../util'); var _Style = require('../Style'); 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; } exports.default = (0, _Style.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' : _util.isIOS ? 'scroll' : 'auto'), _res); if (_util.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 }); } });