import React, { useRef, useEffect } from 'react' import BScroll from '@better-scroll/core' import Movable from '@better-scroll/movable' import picture1 from './oasis_one.png' import picture2 from './oasis_two.png' BScroll.use(Movable) const MultiContent = () => { const wrapperRef = useRef(null) const scrollRef2 = useRef(null) useEffect(() => { const BS1 = new BScroll(wrapperRef.current, { bindToTarget: true, scrollX: true, scrollY: true, freeScroll: true, movable: true, startX: 10, startY: 10, }) const BS2 = (scrollRef2.current = new BScroll(wrapperRef.current, { // use wrapper.children[1] as content specifiedIndexAsContent: 1, bindToTarget: true, scrollX: true, scrollY: true, freeScroll: true, movable: true, startX: 0, startY: 170, })) return () => { BS1.destroy() BS2.destroy() } }, []) const handleClick = () => { scrollRef2.current.putAt('center', 'center') } return (
Cold Oasis
Cold Oasis
Warm Oasis
Warm Oasis
) } export default MultiContent