Reveal.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import React, { useEffect } from 'react'
  21. import { useSelector } from 'react-redux'
  22. import { makeSelectDisplay, makeSelectSlidesCount } from '../selectors'
  23. import Reveal from 'reveal.js'
  24. import 'reveal.js/dist/reveal.css'
  25. import RevealZoom from 'reveal.js/plugin/zoom/plugin'
  26. import { DefaultDisplayParams } from 'containers/Display/constants'
  27. import Display from './Display'
  28. const ShareDisplayReveal: React.FC = () => {
  29. const {
  30. config: { displayParams }
  31. } = useSelector(makeSelectDisplay())
  32. const { autoPlay, autoSlide, transitionStyle, transitionSpeed } =
  33. displayParams || DefaultDisplayParams
  34. const slidesCount = useSelector(makeSelectSlidesCount())
  35. const slideNumberParam = new URLSearchParams(window.location.search).get('p')
  36. const slideNumber = +slideNumberParam
  37. useEffect(() => {
  38. Reveal.initialize({
  39. hash: false,
  40. history: false,
  41. controls: true,
  42. controlsLayout: 'edges',
  43. controlsTutorial: false,
  44. progress: false,
  45. loop: true,
  46. width: '100%',
  47. height: '100%',
  48. margin: 0,
  49. minScale: 1,
  50. maxScale: 1,
  51. autoSlide:
  52. (slideNumber > 0 && slideNumber < slidesCount) || autoPlay === false
  53. ? 0
  54. : autoSlide * 1000,
  55. transition: transitionStyle,
  56. transitionSpeed,
  57. viewDistance: 100,
  58. plugins: [RevealZoom]
  59. })
  60. }, [])
  61. return (
  62. <div className="reveal">
  63. <div className="slides">
  64. <Display targetSlideNumber={slideNumber} />
  65. </div>
  66. </div>
  67. )
  68. }
  69. export default ShareDisplayReveal