diff --git a/packages/dual-channel/src/app/components/embedded-items/index.js b/packages/dual-channel/src/app/components/embedded-items/index.js index b4e7325ee..690922c4a 100644 --- a/packages/dual-channel/src/app/components/embedded-items/index.js +++ b/packages/dual-channel/src/app/components/embedded-items/index.js @@ -7,6 +7,7 @@ import styled, { css } from 'styled-components' import mq from '../../utils/media-query' import { connect } from 'react-redux' import { Waypoint } from 'react-waypoint' +import { offsetTop } from '../../constants/customized-props' const _ = { get, @@ -80,9 +81,9 @@ const ItemViewport = styled.div` } else if (props.sectionsPosition === Waypoint.above) { return `position: absolute; bottom: 50vh;` } else if (props.sectionsPosition === Waypoint.below) { - return `position: absolute; top:0px;` + return `position: absolute; top: 0px;` } - return `position: fixed; top: 0px;` + return `position: fixed; top: ${offsetTop}px;` }} `} ${mq.desktopOnly` diff --git a/packages/dual-channel/src/app/components/sections-entry-points.js b/packages/dual-channel/src/app/components/sections-entry-points.js index f9c807701..366e0d2e1 100644 --- a/packages/dual-channel/src/app/components/sections-entry-points.js +++ b/packages/dual-channel/src/app/components/sections-entry-points.js @@ -3,6 +3,7 @@ import React from 'react' import styled from 'styled-components' import { Waypoint } from 'react-waypoint' import { connect } from 'react-redux' +import { scrollableAncestor } from '../constants/customized-props' const EntryPoint = styled.div` width: 1px; @@ -51,6 +52,7 @@ class _HeadEntryPoint extends React.PureComponent { render() { return ( { const sectionJsx = ( ({ - updatAnchorIndex: dispatch.position.update, + updateAnchorIndex: dispatch.position.update, }) export default connect( diff --git a/packages/dual-channel/src/app/constants/customized-props.js b/packages/dual-channel/src/app/constants/customized-props.js new file mode 100644 index 000000000..dcf51781c --- /dev/null +++ b/packages/dual-channel/src/app/constants/customized-props.js @@ -0,0 +1,16 @@ +const isClientSide = + typeof window !== 'undefined' && typeof window.document !== 'undefined' + +const scrollableAncestorValue = + isClientSide && + document.currentScript.getAttribute('data-scrollable-ancestor') +export const scrollableAncestor = scrollableAncestorValue || undefined + +const offsetTopValue = + isClientSide && document.currentScript.getAttribute('data-offset-top') +export const offsetTop = + offsetTopValue && + Number.isInteger(Number(offsetTopValue)) && + Number(offsetTopValue) > 0 + ? offsetTopValue + : 0