react-awesome-slider icon indicating copy to clipboard operation
react-awesome-slider copied to clipboard

with Caption not working

Open canotech opened this issue 5 years ago • 11 comments

I have the next code, but not working withCaption.

import { Fragment } from 'react'
import { Container } from 'reactstrap'
import AwesomeSlider from 'react-awesome-slider'
import withCaption from 'react-awesome-slider/dist/captioned';
import AnimationStyles from 'react-awesome-slider/src/styled/open-animation/open-animation.scss'
import withAutoplay from 'react-awesome-slider/dist/autoplay'
import { HomeIcon } from '../components/icons'


const AutoPlaySlider = withAutoplay(withCaption(AwesomeSlider))

export default () => {
  return (
    <Fragment>
      <div className="keep-main">
        <Container>
          <div className="keep-title">
            <div className="keep-text">
              Tú pones la casa, <br />
              nosotros la música
            </div>
            <div>
              <HomeIcon width="100" height="100" />
            </div>
          </div>
          <div className="keep-slider">
            <AutoPlaySlider
              animation="openAnimation"
              cssModule={[AnimationStyles]}
              play={true}
              cancelOnInteraction={false}
              interval={3000}
              bullets={false}
              organicArrows={false}
            >
              <div data-src="/static/images/ocesaapp/0/ocesa_app_bg.jpg" />
              <div data-src="/static/images/ocesaapp/1/ocesa_app_bg.jpg" />
              <div data-src="/static/images/ocesaapp/2/ocesa_app_bg.jpg" />
            </AutoPlaySlider>
          </div>
          <div className="keep-tabs"></div>
        </Container>
      </div>
      <style jsx global>{`
        @import 'styles/variables';
        @import 'styles/mixins';
        .keep-main {
          padding-top: 5em;
          background-color: #1a1a1a;
          min-height: 100vh;
        }

        .keep-title {
          display: flex;
          justify-content: flex-start;
          align-items: flex-end;
          flex-flow: row wrap;
          color: $white;

          .keep-text {
            font-family: Nunito;
            font-size: 2.5em;
            @include media-breakpoint-down(sm) {
              font-size: 2em;
            }
          }
        }

        .keep-slider {
          margin-top: 5em;
        }
      `}</style>
    </Fragment>
  )
}

Screen Shot 2020-03-31 at 20 07 27

canotech avatar Apr 01 '20 02:04 canotech

Same here, it looks like something was missed in the deploy. it's looking for captioned in the dist directory but it isn't there

@rcaferati if you've got a moment can you take a look. pulling the source code to see if i can reproduce locally

macsplan avatar May 04 '20 22:05 macsplan

I am implement caption the next form with custom css:

import { Fragment, useState, useEffect } from 'react'
import AwesomeSlider from 'react-awesome-slider'
import withAutoplay from 'react-awesome-slider/dist/autoplay'
import AnimationStyles from 'react-awesome-slider/src/styled/open-animation/open-animation.scss'
import CaptionedStyles from 'react-awesome-slider/src/hoc/captioned-images/styles.scss'

import CaptionedStyles from 'react-awesome-slider/src/hoc/captioned-images/styles.scss'
const AutoPlaySlider = withAutoplay(AwesomeSlider)
const KeepInHome = () => {
const [sliderEvents, setSliderEvents] = useState([])

useEffect(() => {
//fetch data
setSliderEvents(data)
},[])
return (
<AutoPlaySlider
          className="keep-slider-container"
          animation="openAnimation"
          cssModule={[AnimationStyles, CaptionedStyles]}
          play
          cancelOnInteraction={false}
          interval={3000}
          bullets={false}
          organicArrows={false}
          mobileTouch
        >
          {sliderEvents.map((item, i) => {
            return (
              <div key={i} data-src={item.rectangleImageUrl} className="img-content">
                <div className="img-inner">
                  <div className="img-item">
                    <div className="item-title">{item.name}</div>
                    <div className="item-venue">{item.venueName}</div>
                    <div className="keep-links-container">{renderLinks(item)}</div>
                  </div>
                </div>
              </div>
            )
          })}
        </AutoPlaySlider>
)
}

canotech avatar May 04 '20 23:05 canotech

Not seeing captioned.js in the dist folder on my end either. captioned.css is there.

kdevan avatar May 29 '20 01:05 kdevan

same here, captioned.js is not found in the dist folder

victor-sanchez-ccc avatar Jun 05 '20 00:06 victor-sanchez-ccc

Hi, I had the same problem and solved it by building by myself the repo and copying the files from that build

git clone https://github.com/rcaferati/react-awesome-slider/
yarn install
// if you want you can use npm
yarn build

Then copy the files in <fork path>/dist and paste them in <project path>/node_modules/react-awesome-slider/dist.

And now it should work :)

image

4nt0n10M4 avatar Jul 21 '20 11:07 4nt0n10M4

Any update please?

blackr1234 avatar Sep 20 '20 16:09 blackr1234

Ran in to the same issue. I ended up implementing my own caption scheme by using the "onTransitionEnd" event. You can get the currentIndex from the slider reference passed to the event function.

Aviemusca avatar Oct 26 '20 23:10 Aviemusca

Are there any updates?

Tharuja avatar Jan 28 '21 09:01 Tharuja

Caption implementation is available but it's only in the example because(I guess) repo owner didn't want this package to be large(assuming that not everyone would want to use slider with captions). Tl;dr; captioned.js component can be found here :)

trolit avatar Jan 28 '21 10:01 trolit

@trolit but in each new installation I have to add captioned.js file in the dist, since I dont push node modules to my repo in github.. any solution for this? :(

Tharuja avatar Jan 28 '21 10:01 Tharuja

@Tharuja Not React expert 😄 but I had the same problem where I wanted to make more modifications to the slider and at the same time store changes done to that file in repo and I've decided to simply move it to ./src/pages and then in component I've used import MyImport from './myfile.scss'; so you could give a try to use captioned component that way :)

trolit avatar Jan 28 '21 13:01 trolit