{"version":3,"sources":["webpack://_N_E/./node_modules/next/router.js","webpack://_N_E/./components/hooks.tsx","webpack://_N_E/./components/ad/index.tsx","webpack://_N_E/./node_modules/@arsenal/arsenal/modules/event.js","webpack://_N_E/./components/hooks/use-visible.ts","webpack://_N_E/./components/scroll-loader.tsx","webpack://_N_E/./node_modules/core-js/modules/es.array.find-index.js"],"names":["module","exports","useIntervalAnimation","start","max","ref","callback","interval","timerRef","useRef","mouseRef","clear","current","clearTimeout","invoke","setTimeout","mouseEnter","mouseLeave","useEffect","on","off","useCityName","useContext","GlobalStoreContext","state","cityName","useBrandList","dispatch","brands","fetch","getUrl","then","json","data","message","Error","letters","map","item","pinyin","obj","letter","inner","id","name","brand","avatar","toutiaourl","type","payload","list","catch","err","undefined","useScrollSpy","getElements","globalScroll","useState","setCurr","elements","setElements","rootElement","setRootElement","clickRef","initRef","length","observer","IntersectionObserver","changes","forEach","change","ele","target","boundingClientRect","bottom","rootBounds","height","document","documentElement","clientHeight","index","findIndex","element","isIntersecting","root","rootMargin","threshold","observe","disconnect","useCallback","node","Array","from","setCurrent","scrollContainer","offset","offsetValue","parent","parentElement","scrollTop","offsetTop","useScrollSpy_v2","dependencies","elementsRef","observerRef","getBoundingClientRect","top","window","pageYOffset","useFeedAd","category","page","feedAd","setFeedAd","curPage","url","encodeURIComponent","credentials","result","status","logger","warn","JSON","stringify","location","href","useAdStat","eventName","info","customStat","throttleTime","useInView","inView","isVisible","useVisible","adData","useMemo","ad_material_id","materiel_str","ad_target_url","web_url","log_extra","ad_id","id_str","ad_req_id","parse","req_id","sendRef","showTimer","send","sendTeaAdEvent","show","track_url_list","sendAdMonitor","requestId","ad_log_id","eventId","handleClick","custom","click","click_track_url_list","el","opts","supportsPassive","passive","_opts","Object","defineProperty","get","addEventListener","e","attachEvent","concat","removeEventListener","detachEvent","value","one","handler","call","event","ScrollLoader","React","props","verticalMargin","isEmbed","param","rootDom","end","loading","loadMoreHandler","dom","this","HEIGHT","addObserver","prevProps","removeObserver","scrollHeight","prevBottom","unobserve","children","style","$","$findIndex","addToUnscopables","arrayMethodUsesToLength","SKIPS_HOLES","USES_TO_LENGTH","proto","forced","callbackfn","arguments"],"mappings":"yFAAAA,EAAOC,QAAU,EAAQ,S,0ZC+DlB,SAASC,EAAT,GAMmB,QALxBC,aAKwB,MALhB,EAKgB,EAJxBC,EAIwB,EAJxBA,IACAC,EAGwB,EAHxBA,IACAC,EAEwB,EAFxBA,SAEwB,IADxBC,gBACwB,MADb,IACa,EAClBC,EAAWC,mBACXC,EAAWD,kBAAgB,GACjC,SAASE,IACHH,EAASI,SACXC,aAAaL,EAASI,SAG1B,SAASE,IAEHJ,EAASE,UAGbD,IACAH,EAASI,QAAUG,YAAW,WAE5BT,EADaH,EAAQ,EAAIC,EAAM,EAAID,EAAQ,KAE1CI,IAEL,SAASS,IACPN,EAASE,SAAU,EACnBD,IAEF,SAASM,IACPP,EAASE,SAAU,EACnBE,IAEFI,qBAAU,WACRJ,MACC,CAACX,IACJe,qBAAU,WAER,GAAKb,GAAQA,EAAIO,QAKjB,OAFAO,aAAGd,EAAIO,QAAS,aAAcI,GAC9BG,aAAGd,EAAIO,QAAS,aAAcK,GACvB,WACLN,IACAS,cAAIf,EAAIO,QAAS,aAAcI,GAC/BI,cAAIf,EAAIO,QAAS,aAAcK,MAEhC,IAgBE,SAASI,IAEd,OADkBC,qBAAWC,KAArBC,MACKC,SAGR,SAASC,IAAe,MACDJ,qBAAWC,KAA/BC,EADqB,EACrBA,MAAOG,EADc,EACdA,SACf,GAAIH,EAAMI,OACR,OAAOJ,EAAMI,OAEfC,YAAMC,YAAO,kCACVC,MAAK,SAAAC,GACJ,IAAKA,EAAKC,MAAyB,YAAjBD,EAAKE,QACrB,MAAM,IAAIC,MAAM,iCAElB,IAAMC,EAAUJ,EAAKC,KAAKI,KAAI,SAACC,GAAD,OAAeA,EAAKC,UAC5CX,EAASI,EAAKC,KAAKI,KAAI,SAACC,GAC5B,IAAME,EAAW,GAOjB,OANAA,E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,KAAK7H,SAAW,Q,+BAIX,IACCqI,EAAaR,KAAKT,MAAlBiB,SACR,OACE,EAAC,WAAD,KACGA,EACD,SAAKlM,IAAK0L,KAAKD,IAAKU,MAAO,CAAE5H,OAAQ,c,GAnGHyG,kB,kCCd1C,IAAIoB,EAAI,EAAQ,QACZC,EAAa,EAAQ,QAAgCzH,UACrD0H,EAAmB,EAAQ,QAC3BC,EAA0B,EAAQ,QAGlCC,GAAc,EAEdC,EAAiBF,EAHJ,0BAMC,IAAIjH,MAAM,GAAa,WAAE,WAAckH,GAAc,KAIvEJ,EAAE,CAAEjI,OAAQ,QAASuI,OAAO,EAAMC,OAAQH,IAAgBC,GAAkB,CAC1E7H,UAAW,SAAmBgI,GAC5B,OAAOP,EAAWX,KAAMkB,EAAYC,UAAUjJ,OAAS,EAAIiJ,UAAU,QAAK7J,MAK9EsJ,EAjBiB","file":"static/chunks/817331888c2ae025adc1559aab049499cb72fe5b.f357ac62c736b9aecd45.js","sourcesContent":["module.exports = require('./dist/client/router')\n","/* eslint-disable react-hooks/exhaustive-deps */\nimport React, {\n useState,\n useRef,\n useEffect,\n useContext,\n useCallback,\n useLayoutEffect,\n MutableRefObject,\n} from 'react'\nimport { on, off } from '@arsenal/arsenal/modules/event'\nimport Router, { SingletonRouter } from 'next/router'\nimport fetch from 'lib/decorated-fetch'\nimport { logger } from 'lib/slardar-utils'\nimport getUrl from 'lib/url'\nimport Loading from 'Components/loading'\nimport { GlobalStoreContext } from 'Components/store'\n\n// function useIntersection(options) {\n// const [observerEntry, setEntry] = useState({})\n// const elRef = useRef()\n\n// useEffect(() => {\n// const observer = new IntersectionObserver(\n// entries => setEntry(entries[0]),\n// options\n// )\n// observer.observe(elRef.current)\n// return () => observer.disconnect()\n// }, [elRef])\n// return { observerEntry, elRef }\n// }\n\nexport function usePrefetch(urls: string[]) {\n useEffect(() => {\n urls.forEach(url => {\n Router.router && Router.router.prefetch(url)\n })\n }, [])\n}\ninterface IUseIntervalAniamtion {\n /**\n * 起始序号\n */\n start: number\n /**\n * 最大序号\n */\n max: number\n /**\n * 当鼠标在ref范围之内时,停止计时动画\n */\n ref: React.RefObject\n /**\n * 计时到达之后的回调\n * @param curr 要激活的index\n */\n callback(curr: number): void\n /**\n * 时间间隔\n */\n interval?: number\n}\nexport function useIntervalAnimation({\n start = 0,\n max,\n ref,\n callback,\n interval = 5000,\n}: IUseIntervalAniamtion) {\n const timerRef = useRef()\n const mouseRef = useRef(false)\n function clear() {\n if (timerRef.current) {\n clearTimeout(timerRef.current)\n }\n }\n function invoke() {\n // 鼠标在范围之内时,不执行动画\n if (mouseRef.current) {\n return\n }\n clear()\n timerRef.current = setTimeout(() => {\n const next = start + 1 > max ? 0 : start + 1\n callback(next)\n }, interval)\n }\n function mouseEnter() {\n mouseRef.current = true\n clear()\n }\n function mouseLeave() {\n mouseRef.current = false\n invoke()\n }\n useEffect(() => {\n invoke()\n }, [start])\n useEffect(() => {\n // 绑定mouse in与mouse out事件\n if (!ref || !ref.current) {\n return\n }\n on(ref.current, 'mouseenter', mouseEnter)\n on(ref.current, 'mouseleave', mouseLeave)\n return () => {\n clear()\n off(ref.current, 'mouseenter', mouseEnter)\n off(ref.current, 'mouseleave', mouseLeave)\n }\n }, [])\n}\n\n/**\n * 获取城市名,初始状态为undefined,如果获取不到为'',在使用时,尽量如下使用\n```\n const cityName = useCityName()\n useEffect(() => {\n if (typeof cityName === 'undefined') {\n return\n }\n fetch(`/api/?city_name=${encodeURIComponent(cityName.replace('未知', ''))}`)\n }, [cityName])\n\n```\n */\nexport function useCityName() {\n const { state } = useContext(GlobalStoreContext)\n return state.cityName\n}\n\nexport function useBrandList() {\n const { state, dispatch } = useContext(GlobalStoreContext)\n if (state.brands) {\n return state.brands\n }\n fetch(getUrl('/motor/car_page/v1/all_brand/'))\n .then(json => {\n if (!json.data || json.message !== 'success') {\n throw new Error('Data error in fetching brands')\n }\n const letters = json.data.map((item: any) => item.pinyin) as string[]\n const brands = json.data.map((item: any) => {\n const obj: any = {}\n obj.letter = item.pinyin\n obj.data = item.data.map((inner: any) => ({\n id: inner.id,\n name: inner.brand,\n avatar: inner.toutiaourl,\n }))\n return obj\n })\n dispatch({\n type: 'setBrands',\n payload: {\n letters,\n list: brands,\n },\n })\n })\n .catch(err => {\n dispatch({\n type: 'setBrands',\n payload: undefined,\n })\n })\n return\n}\n\n/**\n * 监听滚动联动\n * @param getElements 获取需要监听的元素\n * @returns [current, setCurrent, ref]\n```\nconst [current, setCurrent, ref] = useScrollSpy2(node => {\n return node.children\n})\n...\n
\n
\n
\n
\n
\n
\n
{setCurrent(2)}}>A
\n
\n```\n */\nexport function useScrollSpy(\n getElements: (node: T) => NodeListOf,\n globalScroll = true\n): [\n number,\n (index: number, parent?: any, offset?: number) => void,\n (node: T) => void\n] {\n // 当前滚动到第几个元素\n const [current, setCurr] = useState(0)\n const [elements, setElements] = useState([])\n const [rootElement, setRootElement] = useState(null)\n const clickRef = useRef(false)\n // 初始化是忽略\n const initRef = useRef(true)\n useEffect(() => {\n if (elements.length === 0) {\n return\n }\n const observer: IntersectionObserver = new IntersectionObserver(\n changes => {\n // 初始化时忽略\n if (initRef.current) {\n initRef.current = false\n return\n }\n // 如果是通过ScrollInToView产生的滚动则不执行Observer, 避免冲突\n if (clickRef.current) {\n clickRef.current = false\n return\n }\n changes.forEach(change => {\n const ele = change.target as HTMLElement\n const { bottom } = change.boundingClientRect\n const { height } = change.rootBounds || {\n height: document.documentElement.clientHeight,\n }\n // console.log(change, ele, bottom, height)\n // 只关注顶部变动\n if (bottom <= height) {\n // 离开可视区域,获取最后一个,默认顺序\n // chrome55缺少isIntersecting字段\n const index = elements.findIndex(element => element === ele)\n setCurr(change.isIntersecting === false ? index + 1 : index)\n }\n })\n },\n {\n root: globalScroll ? null : rootElement,\n // root: rootElement.current,\n rootMargin: '0px 0px 0px 0px',\n threshold: [0.0000001],\n }\n )\n // 每个需要监听的区域块\n elements.forEach(element => {\n observer.observe(element)\n })\n return () => {\n observer.disconnect()\n }\n }, [elements.length])\n\n const ref = useCallback((node: T) => {\n if (node !== null) {\n setRootElement(node)\n setElements(Array.from(getElements(node)) as HTMLElement[])\n }\n }, [])\n function setCurrent(\n index: number,\n scrollContainer?: HTMLElement,\n offset?: number\n ): void {\n const offsetValue = offset || 0\n if (elements[index]) {\n clickRef.current = true\n const parent = elements[index].parentElement\n if (scrollContainer) {\n scrollContainer.scrollTop = elements[index].offsetTop - offsetValue\n } else if (parent) {\n parent.scrollTop = elements[index].offsetTop\n }\n\n setCurr(index)\n }\n }\n return [current, setCurrent, ref]\n}\n\n// 与Spy1实现相同的功能 但在实现上做了修改。\n// 主要区别是➡由依赖ref callback 改为依赖dependency (利用useEffect一定是在渲染完成后执行的性质)\n// 并在getELements外加setTimeout延时。\n//(useEffect后,依然有不确定原因的DOM变化,setTimeout是个暂时的解决方案,后续还需探究dom变化原因。)\nexport function useScrollSpy_v2(\n getElements: (node: T) => NodeListOf,\n globalScroll = true,\n dependencies: any[]\n): [\n number,\n (index: number, parent?: any, offset?: number) => void,\n (node: T | null) => void\n] {\n // 当前滚动到第几个元素\n const [current, setCurr] = useState(0)\n const [rootElement, setRootElement] = useState(null)\n const elementsRef = useRef(null)\n const clickRef = useRef(false)\n // 初始化时忽略\n const initRef = useRef(true)\n\n const observerRef = useRef(null)\n useEffect(() => {\n observerRef.current = new IntersectionObserver(\n changes => {\n const elements = elementsRef.current\n if (!elements) {\n return\n }\n\n // 初始化时忽略\n if (initRef.current) {\n initRef.current = false\n return\n }\n // 如果是通过ScrollInToView产生的滚动则不执行Observer, 避免冲突\n if (clickRef.current) {\n clickRef.current = false\n return\n }\n changes.forEach(change => {\n const ele = change.target as HTMLElement\n const { bottom } = change.boundingClientRect\n const { height } = change.rootBounds || {\n height: document.documentElement.clientHeight,\n }\n // console.log(change, ele, bottom, height)\n // 只关注顶部变动\n if (bottom <= height) {\n // 离开可视区域,获取最后一个,默认顺序\n // chrome55缺少isIntersecting字段\n const index = elements.findIndex(element => element === ele)\n setCurr(change.isIntersecting === false ? index + 1 : index)\n }\n })\n },\n {\n root: globalScroll ? null : rootElement,\n // root: rootElement.current,\n rootMargin: '0px 0px 0px 0px',\n threshold: [0.0],\n }\n )\n }, [])\n\n useEffect(() => {\n const observer = observerRef.current\n if (!observer) {\n return\n }\n if (!rootElement) {\n return\n }\n // setTimeout(()=>{\n\n // },0)\n let elements\n\n // 使用setTimeout来确保getElements拿到最新的dom\n setTimeout(() => {\n elements = Array.from(getElements(rootElement))\n\n elementsRef.current = elements\n if (elements.length === 0) {\n return\n }\n // 每个需要监听的区域块\n elements.forEach(element => {\n observer.observe(element)\n })\n }, 300)\n return () => {\n observer.disconnect()\n }\n }, [rootElement, ...dependencies])\n\n const ref = useCallback((node: T | null) => {\n if (node !== null) {\n setRootElement(node)\n }\n }, [])\n\n function setCurrent(\n index: number,\n scrollContainer?: HTMLElement,\n offset?: number\n ): void {\n const offsetValue = offset || 0\n const elements = elementsRef.current\n if (!elements) {\n return\n }\n if (elements[index]) {\n clickRef.current = true\n const parent = elements[index].parentElement\n if (scrollContainer) {\n scrollContainer.scrollTop =\n elements[index].getBoundingClientRect().top -\n offsetValue +\n window.pageYOffset\n } else if (parent) {\n parent.scrollTop =\n elements[index].getBoundingClientRect().top + window.pageYOffset\n }\n\n setCurr(index)\n }\n }\n return [current, setCurrent, ref]\n}\n\nexport interface IFeedAdData {\n type: 2004 | 2005 | 2006\n fix_position: number\n id: number\n id_str: string\n image_list: [\n {\n url: string\n width: number\n height: number\n }\n ]\n image_mode: number\n label: string\n log_extra: string\n ad_log_id: string\n materiel_id: string\n materiel_str: string\n rit: number\n rit_str: string\n source: string\n time: number\n title: string\n web_title: string\n web_url: string\n unique_id_str: string\n inserted?: boolean | undefined\n track_url_list?: string[]\n click_track_url_list?: string[]\n}\n\ninterface IFeedAdResult {\n status: number\n prompts?: string\n data: IFeedAdData[]\n}\n/**\n * 获取feed流广告位\n * @param category 频道名\n * @param page 页面名\n */\nexport function useFeedAd(category: string, page = 'home') {\n const [feedAd, setFeedAd] = useState([])\n const cityName = useCityName()\n\n // 广告接口,资讯页page为information,只针对广告接口对page做修改\n const curPage = page === 'feed' ? 'information' : page\n useEffect(() => {\n if (cityName === undefined) {\n return\n }\n const url = `/motor/ad/m/pc/channel_fixed_position?page=${curPage}&category=${category}&city_name=${encodeURIComponent(\n cityName || ''\n )}`\n fetch(url, {\n credentials: 'include',\n })\n .then((result: Partial) => {\n if (!result || !result.data || result.status !== 0) {\n logger.warn(`[channel feed error],err: ${JSON.stringify(result)}`, {\n url: window?.location?.href,\n })\n return\n }\n setFeedAd(result.data)\n })\n .catch(err => {\n logger.warn(`[channel feed error],err: ${err?.message}`, {\n url: window?.location?.href,\n })\n })\n }, [cityName, page, category])\n return feedAd\n}\n","import useVisible from 'Components/hooks/use-visible'\nimport { useInView } from 'react-intersection-observer'\nimport { useEffect, useMemo, useCallback, useRef } from 'react'\nimport { sendTeaAdEvent, sendAdMonitor } from 'lib/tea-analyze'\nimport { IDefaultAd } from './interface'\n// 根据广告数据返回对应的埋点数据\nexport function getAdStatData(info: IDefaultAd) {\n return {\n ad_material_id: info.materiel_str,\n ad_target_url: info.web_url,\n log_extra: info.log_extra,\n ad_id: info.id_str,\n ad_req_id: JSON.parse(info.log_extra).req_id,\n }\n}\n\ntype TUseAdStat = (\n eventName: {\n /**\n * 下发事件名\n */\n send: string\n /**\n * 展示事件名\n */\n show: string\n /**\n * 点击事件名\n */\n click: string\n },\n info: IDefaultAd,\n customStat?: {\n [key: string]: string | number\n },\n throttleTime?: number\n) => {\n ref(node?: Element | null | undefined): void\n handleClick(custom?: { [key: string]: string | number }): void\n}\n\n// 发送下发和展现事件\nexport const useAdStat: TUseAdStat = (\n eventName,\n info,\n customStat,\n throttleTime = 1000\n) => {\n const [ref, inView] = useInView({\n threshold: 0,\n })\n const isVisible = useVisible()\n const adData = useMemo(() => {\n return {\n ad_material_id: info.materiel_str,\n ad_target_url: info.web_url,\n log_extra: info.log_extra,\n ad_id: info.id_str,\n ad_req_id: JSON.parse(info.log_extra).req_id,\n ...customStat,\n }\n }, [customStat, info.id_str, info.log_extra, info.materiel_str, info.web_url])\n const sendRef = useRef(false)\n const showTimer = useRef()\n useEffect(() => {\n if (adData && !sendRef.current && eventName.send) {\n // 广告下发事件\n sendTeaAdEvent(eventName.send, adData)\n sendRef.current = true\n }\n }, [adData, eventName.send])\n useEffect(() => {\n // 广告展现事件\n // console.log(info.track_url_list, inView, isVisible, adData, eventName.show)\n if (inView && isVisible && eventName.show) {\n if (!showTimer.current) {\n sendTeaAdEvent(eventName.show, adData)\n if (info.track_url_list) {\n info.track_url_list.forEach(url => {\n sendAdMonitor({\n url,\n requestId: info.ad_log_id,\n eventId: eventName.show,\n })\n })\n }\n showTimer.current = window.setTimeout(() => {\n showTimer.current = 0\n }, throttleTime)\n }\n }\n }, [\n inView,\n isVisible,\n adData,\n eventName.show,\n info.track_url_list,\n info.ad_log_id,\n ])\n // 广告点击事件\n const handleClick = useCallback(\n (custom = {}) => {\n sendTeaAdEvent(eventName.click, {\n ...adData,\n ...custom,\n })\n if (info.click_track_url_list) {\n info.click_track_url_list.forEach(url => {\n sendAdMonitor({\n url,\n requestId: info.ad_log_id,\n eventId: eventName.click,\n })\n })\n }\n },\n [adData, eventName.click, info.ad_log_id, info.click_track_url_list]\n )\n\n return {\n ref,\n handleClick,\n }\n}\n","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.on = on;\nexports.one = one;\nexports.off = off;\n\nrequire(\"core-js/modules/es6.object.define-property\");\n\nfunction on(el, eventName, callback, opts) {\n var supportsPassive = false;\n var passive = true;\n\n if (opts) {\n passive = opts.passive;\n }\n\n try {\n var _opts = Object.defineProperty({}, 'passive', {\n get: function get() {\n supportsPassive = true;\n }\n });\n\n window.addEventListener('test', null, _opts);\n } catch (e) {\n return null;\n }\n\n if (el.addEventListener) {\n el.addEventListener(eventName, callback, supportsPassive ? {\n passive: passive\n } : false);\n } else if (el.attachEvent) {\n el.attachEvent(\"on\".concat(eventName), callback);\n }\n\n return callback;\n}\n\nfunction one(el, eventName, callback, opts) {\n var handler = on(el, eventName, function (e) {\n callback.call(el, e || window.event);\n off(el, eventName, handler);\n }, opts);\n return handler;\n}\n\nfunction off(el, eventName, callback) {\n if (el.removeEventListener) {\n el.removeEventListener(eventName, callback);\n } else if (el.detachEvent) {\n el.detachEvent(\"on\".concat(eventName), callback);\n }\n}","import { useContext } from 'react'\nimport { GlobalStoreContext } from 'Components/store'\nexport default function useVisible() {\n const { state } = useContext(GlobalStoreContext)\n return state.isVisible\n}\n","import * as React from 'react'\nexport interface ScrollLoaderProps {\n // 判断是否正在加载中\n loading?: boolean\n /** 是否加载完毕 */\n end: boolean\n /** 垂直方向滚动的边界 */\n verticalMargin?: number\n /**\n * 加载执行的回调\n */\n loadMoreHandler(): void\n isEmbed?: boolean\n}\n\nexport default class ScrollLoader extends React.PureComponent<\n ScrollLoaderProps,\n {},\n any\n> {\n private observer: null | any = null\n\n private HEIGHT = 0\n\n private dom = React.createRef()\n\n private prevBottom?: number\n\n private rootDom?: any\n\n componentDidMount() {\n const { isEmbed } = this.props\n this.rootDom = isEmbed\n ? this.dom.current?.parentElement\n : document.documentElement\n const parent = this.rootDom || document.documentElement\n this.HEIGHT = parent.clientHeight\n this.addObserver()\n }\n\n componentDidUpdate(prevProps: ScrollLoaderProps) {\n const {\n end,\n loading,\n loadMoreHandler,\n verticalMargin = 10,\n isEmbed,\n } = this.props\n // 加载结束,卸载observer\n if (!prevProps.end && end) {\n this.removeObserver()\n } else if (prevProps.end && !end && !this.observer) {\n this.addObserver()\n }\n // 加载完成之后计算一次 确保内容超出屏幕\n let top\n if (isEmbed) {\n this.HEIGHT = this.rootDom?.clientHeight\n const scrollHeight = this.rootDom?.scrollHeight\n const scrollTop = this.rootDom?.scrollTop\n top = scrollHeight - scrollTop\n } else top = this.dom.current?.getBoundingClientRect().top || 0\n if (\n !end &&\n prevProps.loading &&\n !loading &&\n top !== this.prevBottom &&\n top - verticalMargin <= this.HEIGHT\n ) {\n loadMoreHandler()\n this.prevBottom = top\n }\n }\n\n componentWillUnmount() {\n this.removeObserver()\n }\n\n private addObserver = () => {\n const { verticalMargin = 10, isEmbed } = this.props\n const param: any = {\n threshold: [0],\n rootMargin: `${verticalMargin}px 10px`,\n }\n if (isEmbed) param.root = this.rootDom\n this.observer = new IntersectionObserver(changes => {\n changes.forEach(change => {\n // 某些浏览器intersectionRatio有问题,需要再判断位置\n if (!change.isIntersecting) {\n return\n }\n const { end, loading, loadMoreHandler } = this.props\n if (!end && !loading) {\n // 这里的loadMoreHandler一定要这样取,\n // 否则会导致跟hooks共用时的问题\n loadMoreHandler()\n }\n })\n }, param)\n this.observer.observe(this.dom.current)\n }\n\n private removeObserver() {\n if (this.observer) {\n this.observer.unobserve(this.dom.current)\n this.observer = null\n }\n }\n\n render() {\n const { children } = this.props\n return (\n \n {children}\n
\n \n )\n }\n}\n","'use strict';\nvar $ = require('../internals/export');\nvar $findIndex = require('../internals/array-iteration').findIndex;\nvar addToUnscopables = require('../internals/add-to-unscopables');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar FIND_INDEX = 'findIndex';\nvar SKIPS_HOLES = true;\n\nvar USES_TO_LENGTH = arrayMethodUsesToLength(FIND_INDEX);\n\n// Shouldn't skip holes\nif (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; });\n\n// `Array.prototype.findIndex` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.findindex\n$({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH }, {\n findIndex: function findIndex(callbackfn /* , that = undefined */) {\n return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables(FIND_INDEX);\n"],"sourceRoot":""}