Skip to content

Commit

Permalink
fix: fix white flash when changing slides
Browse files Browse the repository at this point in the history
  • Loading branch information
kantord committed Feb 19, 2022
1 parent 63e40fa commit 65c023c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 80 deletions.
66 changes: 66 additions & 0 deletions src/gatsby-theme-mdx-deck/components/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Original source: https://github.com/jxnblk/mdx-deck/blob/master/packages/gatsby-theme/src/components/app.js
import React, { useReducer } from 'react'
import merge from 'lodash.merge'
import Webcam from "react-webcam";
import Context from 'gatsby-theme-mdx-deck/src/context'
import { modes } from 'gatsby-theme-mdx-deck/src/constants'

const WebcamAsBackground = () => {
const videoConstraints = {
width: { min: 640, ideal: 1920, max: 1920 },
height: { min: 400, ideal: 1080, max: 1080 },
facingMode: "user"
};

return (
<Webcam
videoConstraints={videoConstraints}
style={{
width: '100%',
height: '100%',
position: 'fixed',
objectFit: "cover",
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: -1000,
}}
/>
)
}

const reducer = (state, next) =>
typeof next === 'function'
? merge({}, state, next(state))
: merge({}, state, next)

export default props => {
const [state, setState] = useReducer(reducer, {
mode: modes.normal,
step: 0,
metadata: {},
})

const register = (index, key, value) => {
if (state.metadata[index] && state.metadata[index][key]) return
setState({
metadata: {
[index]: {
[key]: value,
},
},
})
}

const context = {
...state,
setState,
register,
}

return <>
<WebcamAsBackground />
<Context.Provider value={context}>{props.children}</Context.Provider>
</>
}
80 changes: 0 additions & 80 deletions src/gatsby-theme-mdx-deck/components/wrapper.js

This file was deleted.

0 comments on commit 65c023c

Please sign in to comment.