UNPKG

rax-scrollview

Version:
105 lines (104 loc) 2.67 kB
"use strict"; var _fmtEvent = _interopRequireDefault(require("./fmtEvent")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } Component({ data: { direction: 'vertical', scrollY: 0, scrollX: 0, scrollIntoViewId: '', scrollWithAnimation: true, scrollAnimationDuration: 400 }, properties: { componentId: { type: String, value: '' }, className: { type: String, value: '' }, styleSheet: { type: String, value: '' }, disableScroll: { type: Boolean, value: false }, horizontal: { type: Boolean, value: false }, endReachedThreshold: { type: Number, value: 500 }, scrollTop: { type: Number, value: 0 }, scrollLeft: { type: Number, value: 0 } }, options: { styleIsolation: 'apply-shared' }, methods: { onEndReached: function onEndReached(e) { var event = (0, _fmtEvent.default)(this.properties, e); this.triggerEvent('onEndReached', event.detail); }, onScroll: function onScroll(e) { var event = (0, _fmtEvent.default)(this.properties, e); event.nativeEvent = { get contentOffset() { return { x: e.detail.scrollLeft, y: e.detail.scrollTop }; }, get contentSize() { return { width: e.detail.scrollWidth, height: e.detail.scrollHeight }; } }; this.triggerEvent('onScroll', event.detail); }, scrollTo: function scrollTo(param) { var _ref = param || {}, _ref$x = _ref.x, x = _ref$x === void 0 ? 0 : _ref$x, _ref$y = _ref.y, y = _ref$y === void 0 ? 0 : _ref$y, _ref$animated = _ref.animated, animated = _ref$animated === void 0 ? true : _ref$animated, _ref$duration = _ref.duration, duration = _ref$duration === void 0 ? 400 : _ref$duration; this.setData({ scrollY: y, scrollX: x, scrollWithAnimation: animated, scrollAnimationDuration: duration }); }, scrollIntoView: function scrollIntoView(param) { var _ref2 = param || {}, id = _ref2.id, _ref2$animated = _ref2.animated, animated = _ref2$animated === void 0 ? true : _ref2$animated, _ref2$duration = _ref2.duration, duration = _ref2$duration === void 0 ? 400 : _ref2$duration; this.setData({ scrollIntoViewId: id, scrollWithAnimation: animated, scrollAnimationDuration: duration }); } } });