react-native-full-calendars
Version:
React Native Full Calendar (RNFC) is an intuitive and powerful calendar component library designed for React Native.
39 lines (38 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useCalendarController = useCalendarController;
var _react = require("react");
var _dateFns = require("date-fns");
function useCalendarController(props) {
const {
swiperRef,
initialDate
} = props;
const goToDatePage = (date, options) => {
const animated = options?.animated ?? false;
const page = (0, _dateFns.differenceInCalendarMonths)(date, initialDate);
swiperRef.current?.setPage(page, {
animated
});
};
const goToNextPage = (0, _react.useCallback)(async (options = {}) => {
const animated = options?.animated ?? true;
swiperRef.current?.nextPage({
animated
});
}, [swiperRef]);
const goToPrevPage = (0, _react.useCallback)(async (options = {}) => {
const animated = options?.animated ?? true;
swiperRef.current?.prevPage({
animated
});
}, [swiperRef]);
return {
goToDatePage,
goToNextPage,
goToPrevPage
};
}
//# sourceMappingURL=useCalendarController.js.map